首页 > 解决方案 > 如何删除“短信”分享权限?

问题描述

谷歌推出了限制短信权限的政策:https: //support.google.com/googleplay/android-developer/answer/9047303

我的应用程序使用共享首选项,但我的应用程序中不需要短信。我需要删除它来解决。

它说:在 2019 年 1 月 9 日之前未能满足政策要求或提交权限声明表的应用可能会从 Google Play 中删除。

我的代码:

private void shareScreenshot(File file) {
    Uri uri = FileProvider.getUriForFile(JogoImparImparActivity.this, BuildConfig.APPLICATION_ID + ".provider",file);
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_SUBJECT, "");
    intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.sharing_text)+" https://play.google.com/store/apps/details?id=loremlorem");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    startActivity(Intent.createChooser(intent, getString(R.string.share_title)));
}

标签: androidpermissionssms

解决方案


当您从您的应用程序共享屏幕截图时,使用Intent.createChooser(),您正在提供 android 设备/sdk,以选择可用于共享图片的应用程序,例如:whatsapp、sms、...该应用程序是根据意图类型(即image/*,)和操作(Intent.ACTION_SEND),这并不违反限制您在问题中引用的短信权限的政策。

查看文章以了解有关 android 系统如何根据意图类型、意图操作、https://developer.android.com/training/sharing/send选择应用程序的更多详细信息


推荐阅读