Android でのパッケージの公開設定のフィルタリング
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 11(API レベル 30)以降をターゲットとするアプリが、デバイスにインストール済みの他のアプリに関する情報をクエリすると、デフォルトで情報がフィルタされます。フィルタされることで、デバイスにインストールされているアプリの一部は検出できなくなりますが、それによって、ユースケースの処理には必要のない、機密になり得る情報にアクセスしてしまう可能性を最小限に抑えられます。
また、パッケージの公開設定がどの程度フィルタされているかによって、Google Play などのアプリストアで、ユーザーに対するアプリのプライバシーとセキュリティの状態を評価できます。たとえば、Google Play では、インストール済みアプリの一覧はユーザーの個人情報および機密情報とみなされます。
アプリの公開範囲を限定すると、他のアプリに関する情報を取得するメソッド(queryIntentActivities()
、getPackageInfo()
、getInstalledApplications()
など)の戻り値に影響が及びます。また、公開範囲を限定することで、他のアプリとの明示的な連携(別のアプリのサービスを起動するなど)も影響を受けます。
一部のパッケージは自動的に公開されます。自分のアプリから他のインストール済みアプリをクエリすることで、自動公開されているパッケージをいつでも検出できます。他のパッケージを確認するには、<queries>
要素を使用して、パッケージの公開レベルを上げることを求める宣言をします。ユースケースのページでは、パッケージの公開レベルを選択して上げる方法の例を紹介しています。そのページに記載されているワークフローを使用すると、ユーザーのプライバシーを保護しながら、一般的なアプリ操作シナリオに対応できます。
まれなケースですが、<queries>
要素でパッケージの公開設定が十分に指定されていない場合でも、QUERY_ALL_PACKAGES
権限を使用できます。アプリを Google Play に公開する場合、この権限を使用するには、承認を得る必要があります。
パッケージの公開動作のテストに関するページには、アプリが他のアプリと連携している場合に、パッケージの公開設定によって異なる動作をテストする方法が記載されています。
参考情報
Android でのパッケージの公開設定の詳細については、次の資料をご覧ください。
ブログ投稿
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-08-27 UTC。
[null,null,["最終更新日 2025-08-27 UTC。"],[],[],null,["# Package visibility filtering on Android\n\nWhen an app targets Android 11 (API level 30) or higher and queries for\ninformation about the other apps that are installed on a device, the system\nfilters this information by default. This filtering behavior means that your app\ncan't detect all the apps installed on a device, which helps minimize the\npotentially sensitive information that your app can access but doesn't need\nto fulfill its use cases.\n\nAlso, filtered package visibility helps app\nstores like Google Play assess the privacy and security that your app provides\nfor users. For example, Google Play considers the list of installed apps to be\n[personal and sensitive user\ndata](https://support.google.com/googleplay/android-developer/answer/10144311#zippy=%2Cexamples-of-common-violations).\n\nLimited app visibility affects the results returned by methods that give\ninformation about other apps, such as\n[`queryIntentActivities()`](/reference/android/content/pm/PackageManager#queryIntentActivities(android.content.Intent,%20int)),\n[`getPackageInfo()`](/reference/android/content/pm/PackageManager#getPackageInfo(java.lang.String,%20int)),\nand\n[`getInstalledApplications()`](/reference/android/content/pm/PackageManager#getInstalledApplications(int)).\nThe limited visibility also affects explicit interactions with other apps, such\nas starting another app's service.\n\nSome packages are [visible\nautomatically](/training/package-visibility/automatic). Your app can always\ndetect these packages in its queries for other installed apps. To view other\npackages, [declare your app's need for increased package\nvisibility](/training/package-visibility/declaring) using the\n[`\u003cqueries\u003e`](/guide/topics/manifest/queries-element) element. The [use\ncases](/training/package-visibility/use-cases) page provides examples of how you\ncan selectively expand package visibility. The workflows described there allow\nyou to fulfill common app interaction scenarios while protecting user privacy.\n\nIn the rare cases where the `\u003cqueries\u003e` element doesn't provide adequate package\nvisibility, you can use the `QUERY_ALL_PACKAGES` permission. If you publish your\napp on Google Play, your app's use of this permission is\n[subject to approval](https://support.google.com/googleplay/android-developer/answer/10158779).\n\nThe page about\n[testing package visibility behavior](/training/package-visibility/testing)\noffers suggestions for how to test behavior changes based on package visibility\nwhen your app relies on interactions with other apps.\n\nAdditional resources\n--------------------\n\nTo learn more about package visibility on Android, view the following materials:\n\n### Blog posts\n\n- [Package visibility in\n Android 11](https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9), available on Medium."]]