Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom actions using implicit intents between applications

I have been trying to get two activities in two separate applications to communicate using a custom action and an implicit intent.

The first application (server), has the following manifest:

<application android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" android:theme="@style/AppTheme">
    <activity android:name="edu.example.sharing.manager.SecureFileShare"
        android:label="@string/title_activity_secure_file_share" android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="edu.example.sharing.action.STORE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="*/*" />
        </intent-filter>
    </activity>
</application>

The second application creates an intent as follows:

File f = new File(s);
Uri fileUri = Uri.fromFile(f);
Intent intent = new Intent();
intent.setData(fileUri);
intent.setAction("edu.example.sharing.action.STORE");               
startActivityForResult(intent, STORE_REQUEST);

Its manifest is normal. When I try to send the intent in the client application, however, I get an activity not found exception:

FATAL EXCEPTION: main
android.content.ActivityNotFoundException: No Activity found to handle Intent {act=edu.example.sharing.action.STORE dat=file:///storage/sdcard0/Download/Alarcon12-Rigoberto.pdf }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
at android.app.Activity.startActivityForResult(Activity.java:3351)
at android.app.Activity.startActivityForResult(Activity.java:3312)

What's causing Android to not recognize the declared activity in the second application? Thanks.

like image 864
skoke Avatar asked Sep 06 '12 09:09

skoke


1 Answers

Firstly You can specify only which application to go to; you cant specify which avtivity to go to; I've already answered how to navigate to another app here; after that your control goes to the other app; you have to handle it there

like image 148
Manoj Kumar Avatar answered Sep 28 '22 09:09

Manoj Kumar