How Do I Get The Launch Intent For My Work Profile App From My App In The Primary Profile?
This question targets Android for work. I have written an app including a DevicePolicyController following this guide. The controller creates a managed profile for my Android devic
Solution 1:
The Solution I came up with cannot happen without the users consent. Maybe there will be a better one in the future. But here is mine:
I added the following intent filter for FooActivity in the Manifest of FooApp.
<intent-filter><actionandroid:name="com.example.FooApp.ACTION_HOMELAUNCHER"/><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter>
Then I added a crossProfileIntentfilter for my work profile (put the following code in the profile administration app currently running in the work profile).
DevicePolicyManagermanager=
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentNamecomponentName= BasicDeviceAdminReceiver.getComponentName(context);
IntentFilterfilterin=newIntentFilter("com.example.FooApp.ACTION_HOMELAUNCHER");
manager.addCrossProfileIntentFilter(componentName, filterin, DevicePolicyManager.FLAG_MANAGED_CAN_ACCESS_PARENT);
In the end, when I want to launch the App in the work profile, I fire the ACTION_HOMELAUNCHER
intent from BarApp and then the user can select, whether he wants to lauch the work profile version or the normal version of FooApp.
Feel free to improve upon this answer.
Post a Comment for "How Do I Get The Launch Intent For My Work Profile App From My App In The Primary Profile?"