中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Android 應(yīng)用程序的快捷方式

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

快捷方式的添加與刪除都是通過廣播來實(shí)現(xiàn)

權(quán)限:

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

    //為程序創(chuàng)建桌面快捷方式  
    Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");  
    //快捷方式的名稱  
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));  
    shortcut.putExtra("duplicate", false); //不允許重復(fù)創(chuàng)建  
    //指定當(dāng)前的Activity為快捷方式啟動(dòng)的對象: 如  
    //com.everest.video.VideoPlayer  
    //注意: ComponentName的第二個(gè)參數(shù)必須加上點(diǎn)號(.),否則快捷方式無法啟動(dòng)相應(yīng)程序  
    ComponentName comp = new ComponentName(this.getPackageName(), "."+this.getLocalClassName());  
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));  
    //快捷方式的圖標(biāo)  
    ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);  
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);  
    sendBroadcast(shortcut);  

    //刪除快捷方式  
    Intent delIntent = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");  
    //快捷方式的名稱  
    delIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));  
      
    //指定當(dāng)前的Activity為快捷方式啟動(dòng)的對象: 如 //com.test.app  
    //注意: ComponentName的第二個(gè)參數(shù)必須是完整的類名(包名+類名),否則無法刪除快捷方式  
    String appClass = this.getPackageName() + "." +this.getLocalClassName();  
    ComponentName compn = new ComponentName(this.getPackageName(), appClass);  
    delIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(compn));  
    sendBroadcast(delIntent);  

標(biāo)簽: 權(quán)限

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:php圖片加水印類

下一篇:異步發(fā)送郵件C#代碼