Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android add my app to "Share" button in gallery

I succeed to add my app in the "share" button in the Android gallery, so if I click on it, my app will start. Can I choose which activity of my app to start? Now it starts the "main" one. Here's my code in the main class:

    .....        
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    String action = intent.getAction();

    // if this is from the share menu
    if (Intent.ACTION_SEND.equals(action)) {   
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            // Get resource path
        }
    }

And the manifest:

<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="image/*" />
</intent-filter>

In reality I succeed in opening a new activity immediately after the "main" starts but I'll prefer to directly open the right one. Thanks

like image 979
phcaze Avatar asked Nov 28 '12 16:11

phcaze


People also ask

How do you customize the sharing panel?

The only customization of Android's Share menu you can do natively is pinning items. To pin something, just press and hold on it for a moment, then choose Pin [app]. If the app has multiple ways to share, such as sending a tweet or a direct message on Twitter, you can choose to pin the one you prefer.


1 Answers

Put your intent filter under activity you want to start into your manifest

 <activity android:name=".Theme"
           android:label="MAIN">
   <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
</activity>

 <activity android:name=".Theme"
           android:label="ActiVITY2">
  <intent-filter>
   <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="image/*" />
  </intent-filter>
</activity>
like image 142
jaumard Avatar answered Oct 02 '22 02:10

jaumard