I am having a app in both user profile as well as managed profile (AFW). I am trying to send broadcast based on package name. intent.setPackage(packageName); mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
Result is both apps (user and managed profiles) get the broadcast.
I want to send broadcast to only managed profile app (So basically user profile should not receive the )
Its possible to send broadcast only to managed profile if we can get managed profile userid.
Now to get userid, we need to listen to broadcast of Managed Profile added.
Steps to register to listen for this broadcast,
Now inside onReceive, how to get userid,
Now send broadcast to that userid (only system can send this broadcast),
Note: userid is actually the folder name which is created under /data/user whenever a managed profile or AFW (Android For Work) is configured on device.