如何在android中发送意图时定制弹出窗口

7ivaypg9  于 2021-07-12  发布在  Java
关注(0)|答案(1)|浏览(315)

我是新来安卓的,我想看起来像这个自定义弹出窗口
这就是我想要的
在这里,我的问题是如何添加自定义图像和文本在上述弹出窗口时,我试图通过意向发送共享的东西。
这是我的代码我应该在这里更改什么?

Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_TEXT,
                    "Intall COC!!"+"https://play.google.com/store/apps/details?id=com.supercell.clashofclans");
            sendIntent.setType("text/plain");
            startActivity(sendIntent);
uplii1fm

uplii1fm1#

检查你的android版本它只支持从android 11开始
使用以下代码

Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Here you can make custom title");
            String shareMessage= "\nhere you can make custom message";
            shareMessage = shareMessage + "Intall CoC!!\"+\"https://play.google.com/store/apps/details?id=com.supercell.clashofclans" + BuildConfig.APPLICATION_ID +"\n";
            shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
            startActivity(Intent.createChooser(shareIntent, "choose one"));

相关问题