'I am not able to launch main activity while provisioning device
This is my AdminReceiver
public class MyDeviceAdminReceiver extends DeviceAdminReceiver {
private final String TAG = MyDeviceAdminReceiver.class.getName();
this method is not calling from receiver ....
@Override
public void onProfileProvisioningComplete(@NonNull Context context, @NonNull Intent intent) {
super.onProfileProvisioningComplete(context, intent);
Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show();
PersistableBundle extras = intent.getParcelableExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE);
Log.d(TAG, "onProfileProvisioningComplete Extras:" + extras.getString("id"));
Toast.makeText(context, "Provision", Toast.LENGTH_LONG).show();
Intent launch = new Intent(context, MainActivity.class);
launch.putExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE, extras);
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(launch);
}
public static ComponentName getComponentName(Context context) {
Toast.makeText(context, "receive", Toast.LENGTH_SHORT).show();
return new ComponentName(context.getApplicationContext(), MyDeviceAdminReceiver.class);
}
This method is called but onProfileComplete is no calling I was trying every possibilities but isn't work please help...
@Override
public void onEnabled(@NonNull Context context, @NonNull Intent intent) {
// Intent launch = new Intent(context, MainActivity.class);
// launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// context.startActivity(launch);
// PersistableBundle extras = intent.getParcelableExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE);
Toast.makeText(context, "enable", Toast.LENGTH_SHORT).show();
}
@Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
super.onReceive(context, intent);
String action = intent.getAction();
Toast.makeText(context, action, Toast.LENGTH_SHORT).show();
if (ACTION_PROFILE_PROVISIONING_COMPLETE.equals(action)){
Toast.makeText(context, "hahha", Toast.LENGTH_SHORT).show();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|