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创建快捷方式:
暂时没有方法,还在研究中,如果大家知道,麻烦能留言指导一下,非常感谢!