【问题标题】:Activity not starts when i try to share from my application当我尝试从我的应用程序共享时,活动未启动
【发布时间】:2015-02-01 02:19:32
【问题描述】:

我为我的活动指定了意图过滤器

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

意图如下

Intent testone = new Intent(Intent.ACTION_SEND);
                        testone.setType("image/*");
                        testone.putExtra(Intent.EXTRA_STREAM,uri_new);

当我尝试从我的应用程序共享时,我的活动未启动,但当我尝试共享图库图片时它开始

【问题讨论】:

  • 添加 startActivity(testone);

标签: android android-intent share intentfilter


【解决方案1】:

首先为新活动创建意图,然后使用它来启动活动 所以有了这个

意图 testone = new Intent(Intent.ACTION_SEND); testone.setType("图片/*"); testone.putExtra(Intent.EXTRA_STREAM,uri_new);

您创建了 Intent,现在只需使用启动 Activity

startActivity(testone);

您可以找到分享意图的完整示例here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-24
    相关资源
    最近更新 更多