Android创建快捷方式,Phonegap创建快捷方式
Android中创建快捷方式:
在主Activity的OnCreate中,
SharedPreferences preferences = getSharedPreferences("count",MODE_WORLD_READABLE);
int count = preferences.getInt("count", 0);
if (count == 0) {
//当前Activity的名字,显示的图标,app的名字
createShortCut(MainActivity.this,R.drawable.ic_launcher,R.string.app_name);
}
Editor editor = preferences.edit();
editor.putInt("count", ++count);
editor.commit();
public void createShortCut(Activity act, int iconResId, int appnameResId) {
Intent shortcutintent = new Intent(
"com.android.launcher.action.INSTALL_SHORTCUT");
shortcutintent.putExtra("duplicate", false);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
act.getString(appnameResId));
Parcelable icon = Intent.ShortcutIconResource.fromContext(
act.getApplicationContext(), iconResId);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
new Intent(act.getApplicationContext(), act.getClass()));
act.sendBroadcast(shortcutintent);
}
AndroidManifest.xml中权限允许:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
了解更多可以看:http://www.xmumu.com/post/2012-04-01/17357119
Phonegap创建快捷方式:
暂时没有方法,还在研究中,如果大家知道,麻烦能留言指导一下,非常感谢!
更多相关文章
- Android Market中产品图标设计原则
- Android图标设计标准和原则
- 【转】Android -- 探究Android的多分辨率支持以及各种类型图标尺
- Android 如何在Launcher桌面创建或者删除快捷图标
- android 5.0以上修改SearchView的搜索图标
- Android标题栏、状态栏图标文字颜色及背景动态变化
- Android Drawable图标生成工具
- android绘图画Chrome图标
- android 4.4 电池电量显示分析(低电量提醒与电池图标)Java 层