【问题标题】:Sharing intent doesn't open on certain devices共享意图无法在某些设备上打开
【发布时间】:2017-06-06 09:32:28
【问题描述】:

我正在使用什么:

 ShareCompat.IntentBuilder
     .from(getActivity())
     .setText("text")
     .setType("text/plain")
     .startChooser();

我也尝试了以下方法:

 Intent sendIntent = new Intent();
 sendIntent.setAction(Intent.ACTION_SEND);
 sendIntent.putExtra(Intent.EXTRA_TEXT, url);
 sendIntent.setType("text/plain");
 context.startActivity(sendIntent);

在我所有的模拟器上,版本从 5 到 7。在上述两个代码中,intent 都会打开,并且我尝试分享的文本成功。

Nexus 5X、HTC One M8 都可以。但是,当我使用三星设备时,当我调用上述两个代码时,版本 5 和 7 不会打开任何东西。

编辑

我在三星安卓版本 5 上关闭了电池优化,它有效吗?然后我再次禁用它,但它继续工作。

【问题讨论】:

    标签: android android-intent share share-intent android-intent-chooser


    【解决方案1】:

    试试这个代码

            Intent intent_share = new Intent();
            intent_share.setAction(Intent.ACTION_SEND);
            intent_share.setFlags(R.drawable.ic_share);
    
            intent_share.putExtra(Intent.EXTRA_TEXT, "www.googleplay.com/acount");
            intent_share.setType("text/plain");
            startActivity(Intent.createChooser(intent_share, "Share it"));
    

    【讨论】:

    • 请检查我的编辑。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-29
    • 1970-01-01
    • 2014-10-27
    • 1970-01-01
    相关资源
    最近更新 更多