美文网首页Android开发经验谈Android开发Android技术知识
记录Intent.createChooser导致意图选择弹窗消失

记录Intent.createChooser导致意图选择弹窗消失

作者: blingbling_5a3f | 来源:发表于2020-02-14 11:51 被阅读0次

1:使用Intent.createChooser的情况

代码

public void clickBtn(View view) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/*");
        startActivity(Intent.createChooser(intent,"分享"));
    }

效果

Demo.gif

应用选择弹窗会由于点击Home键或者最近任务键而消失。

2:不使用Intent.createChooser,直接startActivity(intent)

代码

public void clickBtn(View view) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/*");
        startActivity(intent);
    }

效果

Demo.gif

应用选择弹窗不会由于点击Home键或者最近任务键而消失。

相关文章

网友评论

    本文标题:记录Intent.createChooser导致意图选择弹窗消失

    本文链接:https://www.haomeiwen.com/subject/gzrrfhtx.html