[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Test package visibility behavior\n\nIf your app relies on interactions with other apps to complete its use cases,\nit's useful to test how [package visibility](/training/package-visibility)\nchanges in Android 11 (API level 30) and higher affect your app.\n\nThis guide also gives some suggestions on how to test the behavior changes\nand helps you configure log messages to determine at a more granular\nlevel how your app might be affected.\n\nTest the behavior changes\n-------------------------\n\nTo test whether this behavior change affects your app, complete the\nfollowing steps:\n\n1. Install [Android Studio 3.6.1](/studio) or higher.\n2. Install the latest version of Gradle that Android Studio supports.\n3. Set your app's `targetSdkVersion` to `30` or higher.\n4. Don't include the `\u003cqueries\u003e` element in your app's manifest file.\n5. Call [`getInstalledApplications()`](/reference/android/content/pm/PackageManager#getInstalledApplications(int)) or [`getInstalledPackages()`](/reference/android/content/pm/PackageManager#getInstalledPackages(int)). Both methods return a filtered list when they are successful.\n6. See which features of your app aren't working.\n7. Introduce appropriate [`\u003cqueries\u003e`](/guide/topics/manifest/queries-element) entries to fix those features.\n\nConfigure log messages for package filtering\n--------------------------------------------\n\nTo discover more details about how the default visibility of apps affects your\napp, you can enable log messages for package filtering. If you're developing a\ntest app or debuggable app in Android Studio, the [system log provides this\ncapability](/studio/debug#systemLog) for you. Otherwise, you can run the\nfollowing command in a terminal window to enable it manually: \n\n```\nadb shell pm log-visibility --enable PACKAGE_NAME\n```\n\nThen, whenever packages are filtered out of a `PackageManager` object's return\nvalues, you see a message similar to the following in Logcat: \n\n```\nI/AppsFilter: interaction: PackageSetting{7654321 \\\n com.example.myapp/12345} -\u003e PackageSetting{...} BLOCKED\n```\n| **Caution:** Your app's performance is affected when this flag is enabled. Unless you're testing how package visibility affects your app, disable the logging of messages related to package visibility."]]