欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android編程實現(xiàn)為程序創(chuàng)建快捷方式的方法

 更新時間:2015年11月06日 16:16:19   作者:Jlins  
這篇文章主要介紹了android編程實現(xiàn)為程序創(chuàng)建快捷方式的方法,實例分析了Android創(chuàng)建程序快捷方式的相關設置與功能實現(xiàn)技巧,需要的朋友可以參考下

本文實例講述了android編程實現(xiàn)為程序創(chuàng)建快捷方式的方法。分享給大家供大家參考,具體如下:

/**
* 為程序創(chuàng)建桌面快捷方式
*/
private void addShortcut(){
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); //不允許重復創(chuàng)建
//指定當前的Activity為快捷方式啟動的對象: 如
//com.everest.video.VideoPlayer
//注意: ComponentName的第二個參數(shù)必須加上點號(.),否則快捷方式無法啟動相應程序
ComponentName comp = new ComponentName(this.getPackageName(), "."+this.getLocalClassName());
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));
//快捷方式的圖標
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
sendBroadcast(shortcut);
}

希望本文所述對大家Android程序設計有所幫助。

相關文章

最新評論