I'm developing an application that needs to be called by another application. Both applications will be installed in my Android device. I need application A to search for application B and the call it.
I have the following requirement from my company:
an intent must also have its type attribute set to
application/mycompanyname.comand it will be discovered usingPackageManager.queryIntentActivities(Intent intent, int flags)with the intent described to see if any activity is available.
But I'm having trouble to register it. Since now I've tried this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testpublishintent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".ReceiverDemo">
<intent-filter>
<action android:name="marakana.intent.action.ReceiverDemo" />
</intent-filter>
</receiver>
</application>
</manifest>
And I'm looking for all installed apps like this:
void GetInstalledAppList()
{
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities( mainIntent, 0);
for (Object object : pkgAppsList)
{
ResolveInfo info = (ResolveInfo) object;
Drawable icon = getBaseContext().getPackageManager().getApplicationIcon(info.activityInfo.applicationInfo);
String strAppName = info.activityInfo.applicationInfo.publicSourceDir.toString();
String strPackageName = info.activityInfo.applicationInfo.packageName.toString();
final String title = (String)((info != null) ? getBaseContext().getPackageManager().getApplicationLabel(info.activityInfo.applicationInfo) : "???");
}
}
But I don't know if this is correct as I can see the installed app but not instantiate it. Can anybody correct me please?