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

Android程序開發(fā)之手機(jī)APP創(chuàng)建桌面快捷方式

 更新時(shí)間:2016年04月18日 09:15:38   作者:Jusenr/榮雪-rongsnow  
這篇文章主要介紹了Android程序開發(fā)之手機(jī)APP創(chuàng)建桌面快捷方式 的相關(guān)資料,需要的朋友可以參考下

預(yù)覽效果圖:

需要權(quán)限:

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

配置文件:AndroidManifest.xml

<activity
android:name="com.myself.news.activity.GuideActivity"
android:label="@string/title_activity_guide" >
<intent-filter>
<action android:name="com.myself.news.ACTION_HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> 

在應(yīng)用的閃屏頁面Activity的 oncreate方法調(diào)用 installShortcut();

代碼:

// 創(chuàng)建快捷方式
// com.android.launcher.permission.INSTALL_SHORTCUT
private void installShortcut() {
// 判斷有沒有創(chuàng)建過快捷方式
boolean isCreated = SharedPreferencesUtils.getBoolean(this,
GlobalConstantsUtils.PREF_IS_SHORTCUT_INTALLED, false);
// 判斷是否已經(jīng)創(chuàng)建過
if (!isCreated) {
// 發(fā)廣播
Intent intent = new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
// 圖標(biāo)
// 根據(jù)資源文件id生成Bitmap對象
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory
.decodeResource(getResources(), R.drawable.ic_launcher));
// 名稱
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "手機(jī)安全衛(wèi)士");
// 動(dòng)作
Intent actionIntent = new Intent();
// 跳到主頁面
actionIntent.setAction(GlobalConstantsUtils.ACTION_HOME);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent);
sendBroadcast(intent);
// 標(biāo)記已經(jīng)創(chuàng)建過快捷方式,下次不再創(chuàng)建
SharedPreferencesUtils.setBoolean(this,
GlobalConstantsUtils.PREF_IS_SHORTCUT_INTALLED, true);
}
}

常量工具類GlobalConstantsUtils:

public static final String PREF_IS_SHORTCUT_INTALLED = "is_shortcut_intalled";// 是否已經(jīng)創(chuàng)建快捷方式 
public static final String ACTION_HOME = "com.myself.news.ACTION_HOME";// 跳轉(zhuǎn)到主頁面的ACTION


相關(guān)文章

最新評論