با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
مجوزهای مربوط به موقعیت مکانی، میکروفون، و دوربین به برنامه شما اجازه میدهد به اطلاعات حساس کاربران دسترسی پیدا کند. این پلتفرم شامل مکانیسمهای مختلفی است که در این صفحه توضیح داده شده است تا به کاربران کمک کند تا در جریان قرار گرفتن و کنترل برنامههایی که میتوانند به مکان، میکروفون و دوربین دسترسی داشته باشند، بمانند.
این ویژگیهای سیستم حفظ حریم خصوصی نباید بر نحوه مدیریت برنامهتان با مجوزهای مربوط به مکان، میکروفون و دوربین تأثیر بگذارد، تا زمانی که بهترین شیوههای حفظ حریم خصوصی را دنبال کنید.
به ویژه، مطمئن شوید که موارد زیر را در برنامه خود انجام می دهید:
منتظر بمانید تا به دوربین دستگاه دسترسی پیدا کنید تا کاربر مجوز CAMERA را به برنامه شما اعطا کند.
منتظر بمانید تا به میکروفون دستگاه دسترسی پیدا کنید تا کاربر مجوز RECORD_AUDIO را به برنامه شما اعطا کند.
قبل از درخواست مجوز ACCESS_BACKGROUND_LOCATION صبر کنید تا کاربر مجوز ACCESS_COARSE_LOCATION یا مجوز ACCESS_FINE_LOCATION را به برنامه شما بدهد.
داشبورد حریم خصوصی
شکل 1. صفحه استفاده از موقعیت مکانی، بخشی از داشبورد حریم خصوصی.
در دستگاههای پشتیبانیشده که دارای Android 12 یا بالاتر هستند، صفحه داشبورد حریم خصوصی در تنظیمات سیستم ظاهر میشود. در این صفحه، کاربران میتوانند به صفحههای جداگانهای دسترسی داشته باشند که نشان میدهند برنامهها چه زمانی به اطلاعات مکان، دوربین و میکروفون دسترسی دارند. هر صفحه یک جدول زمانی از زمانی که برنامه های مختلف به نوع خاصی از داده دسترسی پیدا کرده اند را نشان می دهد. شکل 1 جدول زمانی دسترسی به داده ها را برای اطلاعات مکان نشان می دهد.
منطق دسترسی به داده را نشان دهید
برنامه شما می تواند منطقی را برای کاربران فراهم کند تا به آنها کمک کند بفهمند چرا برنامه شما به اطلاعات مکان، دوربین یا میکروفون دسترسی دارد. این منطق می تواند در صفحه جدید داشبورد حریم خصوصی، صفحه مجوزهای برنامه شما یا هر دو ظاهر شود.
برای توضیح اینکه چرا برنامه شما به اطلاعات مکان، دوربین و میکروفون دسترسی دارد، مراحل زیر را کامل کنید:
فعالیتی را اضافه کنید که هنگام شروع، دلیلی برای اینکه چرا برنامه شما نوع خاصی از عملکرد دسترسی به داده را انجام می دهد، ارائه دهد. در این فعالیت، ویژگی android:permission را روی START_VIEW_PERMISSION_USAGE تنظیم کنید.
تصمیم بگیرید که فعالیت منطقی دسترسی به داده شما باید چه چیزی را نشان دهد. برای مثال، ممکن است وبسایت برنامه یا مقاله مرکز راهنمایی را نشان دهید. برای ارائه توضیحات دقیقتر در مورد انواع دادههایی که برنامه شما به آنها دسترسی پیدا میکند، و همچنین زمانی که دسترسی رخ داده است، موارد اضافی را که سیستم در هنگام فراخوانی قصد استفاده از مجوز شامل میشود، مدیریت کنید:
اگر سیستم ACTION_VIEW_PERMISSION_USAGE را فراخواند، برنامه شما میتواند مقدار EXTRA_PERMISSION_GROUP_NAME را بازیابی کند.
بسته به فیلترهای هدفی که اضافه میکنید، کاربران نماد اطلاعاتی را در کنار نام برنامه شما در صفحههای خاصی مشاهده میکنند:
اگر فیلتر قصد را اضافه کنید که حاوی عملکرد VIEW_PERMISSION_USAGE است، کاربران نماد را در صفحه مجوزهای برنامه شما در تنظیمات سیستم میبینند. می توانید این عمل را برای تمام مجوزهای زمان اجرا اعمال کنید.
اگر فیلتر قصد را اضافه کنید که حاوی عملکرد VIEW_PERMISSION_USAGE_FOR_PERIOD است، هر زمان که برنامه شما در صفحه داشبورد حریم خصوصی ظاهر میشود، کاربران نماد کنار نام برنامه شما را میبینند.
وقتی کاربران آن نماد را انتخاب می کنند، فعالیت منطقی برنامه شما شروع می شود.
شکل 2. نشانگرهای میکروفون و دوربین که دسترسی اخیر به داده ها را نشان می دهد.
شاخص ها
در دستگاههایی که اندروید ۱۲ یا بالاتر دارند، وقتی برنامهای به میکروفون یا دوربین دسترسی پیدا میکند، نمادی در نوار وضعیت ظاهر میشود. اگر برنامه در حالت همهجانبه است، نماد در گوشه سمت راست بالای صفحه ظاهر می شود. کاربران می توانند تنظیمات سریع را باز کرده و نماد را انتخاب کنند تا ببینند کدام برنامه ها در حال حاضر از میکروفون یا دوربین استفاده می کنند. شکل 2 نمونه ای از اسکرین شات را نشان می دهد که حاوی نمادها است.
مکان نمایشگرها را شناسایی کنید
اگر برنامه شما از حالت همهجانبه یا یک رابط کاربری تمام صفحه پشتیبانی می کند، ممکن است نشانگرها برای لحظه ای با رابط کاربری برنامه شما همپوشانی داشته باشند. برای کمک به تطبیق رابط کاربری خود با این شاخصها، سیستم متد getPrivacyIndicatorBounds() را معرفی میکند که قطعه کد زیر نشان میدهد. با استفاده از این API، میتوانید محدودههایی را که ممکن است نشانگرها ظاهر شوند، شناسایی کنید. پس از آن ممکن است تصمیم بگیرید که رابط کاربری صفحه نمایش خود را متفاوت سازماندهی کنید.
کاتلین
view.setOnApplyWindowInsetsListener{view,windowInsets->
valindicatorBounds=windowInsets.getPrivacyIndicatorBounds()// change your UI to avoid overlappingwindowInsets}
تغییر وضعیت می دهد
شکل 3. تعویض میکروفون و دوربین در تنظیمات سریع.
در دستگاههای پشتیبانیشده که دارای Android 12 یا بالاتر هستند، کاربران میتوانند با فشار دادن یک گزینه جابجایی، دسترسی دوربین و میکروفون را برای همه برنامههای دستگاه فعال یا غیرفعال کنند. کاربران می توانند از تنظیمات سریع ، همانطور که در شکل 3 نشان داده شده است، یا از صفحه حریم خصوصی در تنظیمات سیستم، به گزینه های قابل تغییر دسترسی داشته باشند.
کلیدهای دوربین و میکروفون بر روی همه برنامه های دستگاه تأثیر می گذارد:
وقتی کاربر دسترسی به دوربین را خاموش می کند، برنامه شما یک فید دوربین خالی دریافت می کند.
وقتی کاربر دسترسی میکروفون را خاموش می کند، برنامه شما صدای بی صدا را دریافت می کند. علاوه بر این، سنسورهای حرکت بدون توجه به اینکه مجوز HIGH_SAMPLING_RATE_SENSORS را اعلام کردهاید، دارای نرخ محدود هستند .
وقتی کاربر دسترسی به دوربین یا میکروفون را خاموش میکند، سپس برنامهای را راهاندازی میکند که نیاز به دسترسی به اطلاعات دوربین یا میکروفون دارد، سیستم به کاربر یادآوری میکند که ضامن کل دستگاه خاموش است.
پشتیبانی دستگاه را بررسی کنید
برای بررسی اینکه آیا دستگاهی از کلیدهای میکروفون و دوربین پشتیبانی میکند، منطقی را که در قطعه کد زیر ظاهر میشود اضافه کنید:
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی."],[],[],null,["The permissions related to location, microphone, and camera grant your app\naccess to particularly sensitive information about users. The platform includes\nseveral mechanisms, described on this page, to help users stay informed and in\ncontrol over which apps can access location, microphone, and camera.\n\nThese privacy-preserving system features shouldn't affect how your app handles\nthe permissions related to location, microphone, and camera, as long as you\n[follow privacy best practices](/privacy/best-practices).\n\nIn particular, make sure you do the following in your app:\n\n- Wait to access the device's camera until the user has granted the [`CAMERA`](/reference/android/Manifest.permission#CAMERA) permission to your app.\n- Wait to access the device's microphone until the user has granted the [`RECORD_AUDIO`](/reference/android/Manifest.permission#RECORD_AUDIO) permission to your app.\n- Wait until the user interacts with a feature in your app that requires location before you request the [`ACCESS_COARSE_LOCATION`](/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION) permission or the [`ACCESS_FINE_LOCATION`](/reference/android/Manifest.permission#ACCESS_FINE_LOCATION) permission, as described in the guide on how to [request location\n permissions](/training/location/permissions#request-location-access-runtime).\n- Wait until the user grants your app either the `ACCESS_COARSE_LOCATION` permission or the `ACCESS_FINE_LOCATION` permission before you request the [`ACCESS_BACKGROUND_LOCATION`](/reference/android/Manifest.permission#ACCESS_BACKGROUND_LOCATION) permission.\n\nPrivacy Dashboard \n**Figure 1.** Location usage screen, part of the Privacy Dashboard.\n\nOn supported devices that run Android 12 or higher, a Privacy\nDashboard screen appears in system settings. On this screen, users can access\nseparate screens that show when apps access location, camera, and microphone\ninformation. Each screen shows a timeline of when different apps have accessed a\nparticular type of data. Figure 1 shows the data access timeline for location\ninformation.\n\nShow rationale for data access\n\nYour app can provide a rationale for users to help them understand why your app\naccesses location, camera, or microphone information. This rationale can appear\non the new Privacy Dashboard screen, your app's permissions screen, or both.\n\nTo explain why your app accesses location, camera, and microphone information,\ncomplete the following steps:\n\n1. Add an activity that, when started, provides some rationale for why your app\n performs a particular type of data access action. Within this activity, set the\n [`android:permission`](/guide/topics/manifest/activity-element#prmsn) attribute\n to [`START_VIEW_PERMISSION_USAGE`](/reference/android/Manifest.permission#START_VIEW_PERMISSION_USAGE).\n\n If your app targets Android 12 or higher, you must explicitly\n [define a value for the `android:exported`\n attribute](/about/versions/12/behavior-changes-12#exported).\n2. Add the following intent filter to the newly-added activity:\n\n ```xml\n \u003c!-- android:exported required if you target Android 12. --\u003e\n \u003cactivity android:name=\".DataAccessRationaleActivity\"\n android:permission=\"android.permission.START_VIEW_PERMISSION_USAGE\"\n android:exported=\"true\"\u003e\n \u003c!-- VIEW_PERMISSION_USAGE shows a selectable information icon on\n your app permission's page in system settings.\n VIEW_PERMISSION_USAGE_FOR_PERIOD shows a selectable information\n icon on the Privacy Dashboard screen. --\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"android.intent.action.VIEW_PERMISSION_USAGE\" /\u003e\n \u003caction android:name=\"android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD\" /\u003e\n \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n ...\n \u003c/intent-filter\u003e\n \u003c/activity\u003e\n ```\n3. Decide what your data access rationale activity should show. For example, you\n might show your app's website or a help center article. To provide a more\n detailed explanation about the types of data that your app accesses, as well as\n when the access occurred, handle the extras that the system includes when it\n invokes the permission usage intent:\n\n - If the system invokes `ACTION_VIEW_PERMISSION_USAGE`, your app can retrieve a value for [`EXTRA_PERMISSION_GROUP_NAME`](/reference/android/content/Intent#EXTRA_PERMISSION_GROUP_NAME).\n - If the system invokes `ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD`, your app can retrieve values for `EXTRA_PERMISSION_GROUP_NAME`, [`EXTRA_ATTRIBUTION_TAGS`](/reference/android/content/Intent#EXTRA_ATTRIBUTION_TAGS), [`EXTRA_START_TIME`](/reference/android/content/Intent#EXTRA_START_TIME), and [`EXTRA_END_TIME`](/reference/android/content/Intent#EXTRA_END_TIME).\n\nDepending on which intent filters you add, users see an information icon\nnext to your app's name on certain screens:\n\n- If you add the intent filter that contains the `VIEW_PERMISSION_USAGE` action, users see the icon on your app's permissions page in system settings. You can apply this action to all runtime permissions.\n- If you add the intent filter that contains the `VIEW_PERMISSION_USAGE_FOR_PERIOD` action, users see the icon next to your app's name whenever your app appears in the Privacy Dashboard screen.\n\nWhen users select that icon, your app's rationale activity is started. \n**Figure 2.** Microphone and camera indicators, which show recent data access.\n\nIndicators **Note:** The icon mentioned in this section shouldn't require changes to your app's logic, as long as you [follow privacy best\n| practices](/privacy/best-practices).\n\nOn devices that run Android 12 or higher, when an app accesses\nthe microphone or camera, an icon appears in the status bar. If the app is in\n[immersive mode](/training/system-ui/immersive#immersive), the icon appears in\nthe upper-right corner of the screen. Users can open Quick Settings and select\nthe icon to view which apps are currently using the microphone or camera.\nFigure 2 shows an example screenshot that contains the icons.\n\nIdentify the screen location of indicators\n\nIf your app supports immersive mode or a full-screen UI, the indicators might\nmomentarily overlap your app's UI. To help adapt your UI to these indicators,\nthe system introduces the\n[`getPrivacyIndicatorBounds()`](/reference/android/view/WindowInsets.Builder#setPrivacyIndicatorBounds(android.graphics.Rect))\nmethod, which the following code snippet demonstrates. Using this API, you can\nidentify the bounds where the indicators might appear. You might then decide to\norganize your screen's UI differently. \n\nKotlin \n\n```kotlin\nview.setOnApplyWindowInsetsListener { view, windowInsets -\u003e\n val indicatorBounds = windowInsets.getPrivacyIndicatorBounds()\n // change your UI to avoid overlapping\n windowInsets\n}\n```\n\nToggles **Note:** The toggles mentioned in this section shouldn't require changes to your app's logic, as long as you [follow privacy best\npractices](/privacy/best-practices). \n**Figure 3.** Microphone and camera toggles in Quick Settings.\n\nOn [supported devices](#toggles-check-device-support) that run\nAndroid 12 or higher, users can enable and disable camera and\nmicrophone access for all apps on the device by pressing a single toggle\noption. Users can access the toggleable options from [Quick\nSettings](https://support.google.com/android/answer/9083864), as shown in\nfigure 3, or from the Privacy screen in system settings.\n\nThe camera and microphone toggles affect all apps on the device:\n\n- When the user turns off camera access, your app receives a blank camera feed.\n- When the user turns off microphone access, your app receives silent audio.\n Additionally, [motion sensors are\n rate-limited](/guide/topics/sensors/sensors_overview#sensors-rate-limiting),\n regardless of whether you declare the\n [`HIGH_SAMPLING_RATE_SENSORS`](/reference/android/Manifest.permission#HIGH_SAMPLING_RATE_SENSORS)\n permission.\n\n | **Note:** When the user places a call to emergency services, such as 911, the system turns on microphone access. This behavior preserves user safety.\n\nWhen the user turns off access to camera or microphone, then\nlaunches an app that needs access to camera or microphone information, the\nsystem reminds the user that the device-wide toggle is turned off.\n\nCheck device support\n\nTo check whether a device supports microphone and camera toggles, add the logic\nthat appears in the following code snippet: \n\nKotlin \n\n```kotlin\nval sensorPrivacyManager = applicationContext\n .getSystemService(SensorPrivacyManager::class.java)\n as SensorPrivacyManager\nval supportsMicrophoneToggle = sensorPrivacyManager\n .supportsSensorToggle(Sensors.MICROPHONE)\nval supportsCameraToggle = sensorPrivacyManager\n .supportsSensorToggle(Sensors.CAMERA)\n```\n\nJava \n\n```java\nSensorPrivacyManager sensorPrivacyManager = getApplicationContext()\n .getSystemService(SensorPrivacyManager.class);\nboolean supportsMicrophoneToggle = sensorPrivacyManager\n .supportsSensorToggle(Sensors.MICROPHONE);\nboolean supportsCameraToggle = sensorPrivacyManager\n .supportsSensorToggle(Sensors.CAMERA);\n```"]]