Android的加入我的应用程序QUOT&;分享"在画廊按钮 [英] Android add my app to "Share" button in gallery

查看:153
本文介绍了Android的加入我的应用程序QUOT&;分享"在画廊按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功加入我的应用程序中的共享按钮,在Android的画廊,所以如果我点击它,我的应用程序将启动。我可以选择启动哪个我的应用程序的活动? 现在,它开始的主之一。这是我的code。在主类:

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
        }
    }

和清单:

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

在现实中,我成功了主开始后,立即打开一个新的活动,但我会preFER直接打开正确的。 谢谢

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

推荐答案

把你的意图过滤器下的活动要开始进入你的清单

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>

这篇关于Android的加入我的应用程序QUOT&;分享&QUOT;在画廊按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆