با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این راهنما نحوه تشخیص نمایه کاری در دستگاه را نشان می دهد. این فقط برای نمایه های کاری که توسط برنامه خط مشی دستگاه Android مدیریت می شود اعمال می شود.
تشخیص دهید که آیا برنامه در نمایه کاری در حال اجرا است یا خیر
روش زیر بررسی میکند که آیا برنامه تماس در نمایه کاری مدیریت شده توسط برنامه سیاست دستگاه Android اجرا میشود یا خیر.
برای تعیین اینکه آیا دستگاهی دارای نمایه کاری است که توسط برنامه Android Device Policy مدیریت می شود، از روش زیر استفاده کنید. این را می توان از هر حالت مدیریتی فراخوانی کرد. در صورت وجود نمایه کاری که توسط برنامه سیاست دستگاه Android مدیریت میشود، از یک برنامه در نمایه شخصی ، درخواست intent com.google.android.apps.work.clouddpc.ACTION_DETECT_WORK_PROFILE باید به عنوان یک هدف بین نمایه حل شود. این روش تنها زمانی true برمی گردد که از نمایه شخصی دستگاهی که چنین نمایه کاری دارد فراخوانی شود.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[],["To detect a work profile, utilize the `DevicePolicyManager` to check if the app is the profile owner using `isProfileOwnerApp(\"com.google.android.apps.work.clouddpc\")`. To determine if a device *has* a work profile, query for the intent `com.google.android.apps.work.clouddpc.ACTION_DETECT_WORK_PROFILE`. On Android 11+, check if any activity from `queryIntentActivities` has `isCrossProfileIntentForwarderActivity` set. Prior to Android 11, check if the activity name is `com.android.internal.app.ForwardIntentToManagedProfile`.\n"],null,["# Work profile detection\n\nThis guide illustrates how to detect a work profile on a device. It applies only\nto work profiles managed by the Android Device policy app.\n\nDetect if the app is running inside a work profile\n--------------------------------------------------\n\nThe following method checks if the calling app is running within a work profile\nmanaged by the Android Device Policy app. \n\n### Kotlin\n\n fun isInsideWorkProfile(): Boolean {\n val devicePolicyManager = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager\n\n return devicePolicyManager.isProfileOwnerApp(\"com.google.android.apps.work.clouddpc\")\n }\n\n### Java\n\n boolean isInsideWorkProfile() {\n DevicePolicyManager devicePolicyManager = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);\n\n return devicePolicyManager.isProfileOwnerApp(\"com.google.android.apps.work.clouddpc\");\n }\n\nDetect if the device has a work profile\n---------------------------------------\n\nTo determine if a device has a work profile managed by the Android Device Policy\napp, use the following method. This can be called from any management mode. From\nan app in the *personal* profile, querying for the intent\n`com.google.android.apps.work.clouddpc.ACTION_DETECT_WORK_PROFILE` should\nresolve as a cross-profile intent if a work profile managed by the Android\nDevice Policy app exists. This method will only return `true` when called from\nthe *personal* profile of a device that has such a work profile.\n| **Note:** To determine if the app itself is running inside a work profile, use the method described in the previous section.\n\n### Android 11 and later:\n\n### Kotlin\n\n fun hasWorkProfile(): Boolean {\n val intent = Intent(\"com.google.android.apps.work.clouddpc.ACTION_DETECT_WORK_PROFILE\")\n val activities = context.packageManager.queryIntentActivities(intent, 0)\n return activities.any { it.isCrossProfileIntentForwarderActivity }\n }\n\n### Java\n\n boolean hasWorkProfile() {\n Intent intent = new Intent(\"com.google.android.apps.work.clouddpc.ACTION_DETECT_WORK_PROFILE\");\n List\u003cResolveInfo\u003e activities = context.getPackageManager().queryIntentActivities(intent, 0);\n return activities.stream()\n .anyMatch(\n (ResolveInfo resolveInfo) -\u003e {\n return resolveInfo.isCrossProfileIntentForwarderActivity();\n });\n }\n\n### Prior to Android 11:\n\n### Kotlin\n\n fun hasWorkProfile(): Boolean {\n val intent = Intent(\"com.google.android.apps.work.clouddpc.ACTION_DETECT_WORK_PROFILE\")\n val activities = context.packageManager.queryIntentActivities(intent, 0)\n return activities.any { it.activityInfo.name == \"com.android.internal.app.ForwardIntentToManagedProfile\" }\n }\n\n### Java\n\n boolean hasWorkProfile() {\n Intent intent = new Intent(\"com.google.android.apps.work.clouddpc.ACTION_DETECT_WORK_PROFILE\");\n List\u003cResolveInfo\u003e activities = context.getPackageManager().queryIntentActivities(intent, 0);\n return activities.stream()\n .anyMatch(\n (ResolveInfo resolveInfo) -\u003e {\n return resolveInfo.activityInfo.name.equals(\"com.android.internal.app.ForwardIntentToManagedProfile\");\n });\n }"]]