I have written two different Android applications.
I wish for one application to create an intent and in turn, start an activity in the other application.
The first application which creates the intent has the following code:
Intent intent = new Intent();
intent.setAction("com.example.printtest.ACTION_PRINT");
Uri.Builder builder = new Uri.Builder();
builder.scheme("PrintAPI")
.authority("StartPrintJob")
.appendQueryParameter("appId", "aaa");
Uri uri = builder.build();
intent.setData(uri);
startActivity(intent);
The second application which I want to receive the intent has the following defined in it's manifest:
<activity android:name=".PrintActivity">
<intent-filter>
<action android:name="com.example.printtest.ACTION_PRINT"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
From what I understand, the activity in the second application should be recognized as the one to start this intent. However, the same exception is thrown each time. The exception being thrown is:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapp, PID: 21665
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.printtest.ACTION_PRINT dat=PrintAPI://StartPrintJob?appId=aaa }
Is there something that I'm missing?
Is it valid to start an activity in another application just by setting action
and data
on an intent?
Any help or advice is greatly appreciated.