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

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

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

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

uplii1fm1#

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

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

相关问题