addPersistentPreferredActivity on api21

元气小坏坏 提交于 2019-12-10 17:16:48

问题


I'm trying to add persisted activity to intent filter, I am profile owner and device owner and this is verified and I have no security exception but still my activity is not interrupting the call, not sure what to do next ...help please

ComponentName adminComponent = new ComponentName(getApplicationContext(), EnforcerDeviceAdminReceiver.class);
ComponentName handlerComponent = new ComponentName(getApplicationContext(), HandlerActivity.class);

devicePolicyManager.clearPackagePersistentPreferredActivities(adminComponent, getPackageName());

IntentFilter intentFilter = new IntentFilter(INTENT_ACTION);
intentFilter.addCategory(Intent.CATEGORY_DEFAULT);

devicePolicyManager.addPersistentPreferredActivity(adminComponent, intentFilter, handlerComponent);

After adding this I am launching startActivity(new Intent(INTENT_ACTION)); from another application but this is not interrupted by the above activity.


回答1:


I've tried several things without being able to make it works.

However, the source code seems to do what the documentation say, so I guess the feature is currently broken (Android 5.0).



来源:https://stackoverflow.com/questions/28504495/addpersistentpreferredactivity-on-api21

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!