且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Intent Action_dial 在 android 11 中不起作用

更新时间:2023-02-11 17:12:21

你的问题出在代码行intent.resolveActivity(getPackageManager()).当你调用resolveActivity时,你会得到这样的警告:

Your problem lies in the line of code intent.resolveActivity(getPackageManager()). When you call resolveActivity, you will get a warning like this:

考虑在调用此方法时向清单添加声明;详情请参阅 https://g.co/dev/packagevisibility

Consider adding a declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details

查看PackageManager下的文档,会看到这个说明:

Check the document under PackageManager, you will see this note:

注意:如果您的应用面向 Android 11(API 级别 30)或更高版本,则此类中的每个方法都会返回过滤后的应用列表.详细了解如何管理包可见性.

Note: If your app targets Android 11 (API level 30) or higher, the methods in this class each return a filtered list of apps. Learn more about how to manage package visibility.

那是什么意思?

在 android 11 中,Google 添加了包可见性策略.应用程序现在可以更严格地控​​制查看其他应用程序.您的应用程序将无法查看或访问您的应用程序之外的应用程序.

In android 11, Google added package visibility policy. Apps now have tighter control over viewing other apps. Your application will not be able to view or access applications outside of your application.

你需要做什么?

您需要做的就是在 AndroidManifest.xml 中添加以下代码行:

All you need to do is add below line of code to AndroidManifest.xml:

<manifest>
    <queries>
        <!-- Specific intents you query for -->
        <intent>
            <action android:name="android.intent.action.DIAL" />
        </intent>
    </queries>
</manifest>

更多信息:

  1. Android 11 中的包可见性
  2. Android 上的包可见性过滤