码迷,mamicode.com
首页 > 移动开发 > 详细

Android创建快捷方式图标

时间:2015-03-03 11:42:22      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:android

一个方法,在APP需要的时候调用该方法即可:

public void createShortcutIconInHomeScreen() {

		Intent addIntent = new Intent();
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent());
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "快捷方式名字");

		// 不重复创建快捷方式图标。
		addIntent.putExtra("duplicate", false);

		// R.drawable.app_logo 快捷方式的图标icon。
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
				Intent.ShortcutIconResource.fromContext(
						getApplicationContext(), R.drawable.app_logo));
		addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
		getApplicationContext().sendBroadcast(addIntent);
	}

Android创建快捷方式图标

标签:android

原文地址:http://blog.csdn.net/zhangphil/article/details/44035379

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!