Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my Android app appear in the share list of another specific app

<action android:name="android.intent.action.SEND" />      <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> 

this is in my manifest file

this will make my app appear on the share list of all apps but I want my app to appear in the share list of another specific app and I don't own the other app

like image 235
Android Ninja Avatar asked Jun 19 '12 05:06

Android Ninja


1 Answers

Add this code in the activity you want opened first when sharing a content from outside the app, call this method in onCreate()

private void onSharedIntent() {     Intent receiverdIntent = getIntent();     String receivedAction = receiverdIntent.getAction();     String receivedType = receiverdIntent.getType();      if (receivedAction.equals(Intent.ACTION_SEND)) {          // check mime type          if (receivedType.startsWith("text/")) {              String receivedText = receiverdIntent                     .getStringExtra(Intent.EXTRA_TEXT);             if (receivedText != null) {                 //do your stuff             }         }          else if (receivedType.startsWith("image/")) {              Uri receiveUri = (Uri) receiverdIntent                     .getParcelableExtra(Intent.EXTRA_STREAM);              if (receiveUri != null) {                 //do your stuff                 fileUri = receiveUri;// save to your own Uri object                  Log.e(TAG,receiveUri.toString());             }         }      } else if (receivedAction.equals(Intent.ACTION_MAIN)) {          Log.e(TAG, "onSharedIntent: nothing shared" );     } } 

Add this in Manifest,

 <activity             android:name="your-package-name.YourActivity">             <intent-filter>                 <action android:name="android.intent.action.SEND" />                   <category android:name="android.intent.category.DEFAULT" />                       <data android:mimeType="image/*" />                 <data android:mimeType="text/*" />             </intent-filter>         </activity> 
like image 180
Soropromo Avatar answered Sep 21 '22 10:09

Soropromo