創建程序圖標


Intent addShortCut = new Intent(  
                        "com.android.launcher.action.INSTALL_SHORTCUT");  
                // 加載app名  
                String title = getResources().getString(R.string.app_name);  
                // 加載app的logo  
                Parcelable icon = Intent.ShortcutIconResource.fromContext(  
                        ShortCutsActivity.this, R.drawable.ic_launcher);  
                //點擊快捷方式後操作Intent,快捷方式建立後,再次啓動該程序  
                Intent intent = new Intent(ShortCutsActivity.this, ShortCutsActivity.class);  
                //設置快捷方式的標題  
                addShortCut.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);  
                //設置快捷方式的圖標  
                addShortCut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);  
                //設置快捷方式對應的Intent  
                addShortCut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);  
                //發送廣播添加快捷方式  
                sendBroadcast(addShortCut);  

權限


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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章