`
ithinkfeed
  • 浏览: 91743 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Android创建应用程序快捷方式(shortcut)

 
阅读更多

Action:

 

 

private static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
private static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";  
 

Intent shortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);  
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,  
                getString(R.string.app_name));  
shortcutIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, false);  
Intent intent = new Intent();  
intent.setComponent(new ComponentName(this.getPackageName(),  
                ".Splash"));   
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);  
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,  Intent.ShortcutIconResource.fromContext(this,  
                        R.drawable.icon));  
sendBroadcast(shortcutIntent);

 Uses permission:

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>  
 
分享到:
评论
2 楼 1846396994 2012-04-21  
总结的关于添加和删除及判断是否存在快捷方式,Android应用添加(创建)和删除及判断是否存在桌面快捷方式
1 楼 HHLgloden110 2011-10-20  
老兄,请教一个问题,
给应用程序创建快捷方式时,这个快捷方式的点击事件并不是打开给应用程序,而是执行应用程序里的一个服务,那快捷方式的事件要怎么写呢?直接通过intent不能实现跳转到服务,老是提示“应用程序尚未安装在你的手机上”
如何解决阿???指点下

相关推荐

Global site tag (gtag.js) - Google Analytics