Android创建快捷方式图标

2015-04-09 0 769
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);  
        }  

添加权限:

    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>     

遇见资源网 java Android创建快捷方式图标 http://www.ox520.com/9166.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务