改动app的默认设置(包含改动默认launcher)

1、改为自己的launcher

ComponentName component = new ComponentName(
context.getPackageName(), MainActivity.class.getName());//红色为自己的launcher入口
ComponentName[] components = new ComponentName[] {
new ComponentName("com.android.launcher",
"com.android.launcher2.Launcher"), component };
pm.clearPackagePreferredActivities("com.android.launcher");//清除默认launcher
pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY,
components, component);

2、改为系统的launcher


ComponentName component = new ComponentName("com.android.launcher",
"com.android.launcher2.Launcher");
ComponentName[] components = new ComponentName[] {
new ComponentName(context.getPackageName(), MainActivity.class.getName()), component };
pm.clearPackagePreferredActivities("com.android.launcher");
pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY,
components, component);


3、參考资料

http://blog.csdn.net/wh_19910525/article/details/39025425

http://blog.csdn.net/lwyygydx/article/details/42873829

http://www.07net01.com/2014/09/79947.html

http://blog.csdn.net/jia4525036/article/details/18036765


posted @ 2017-04-19 16:57  yangykaifa  阅读(740)  评论(0编辑  收藏  举报