Android创建快捷方式,Phonegap创建快捷方式
2014-04-22 14:27
513 查看
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创建快捷方式:
暂时没有方法,还在研究中,如果大家知道,麻烦能留言指导一下,非常感谢!
在主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学习笔记]Bitmap,BitmapDrawable,BitmapFactory学习笔记
- android学习笔记---fragment适配手机和平板
- Android中的ID能否重名
- android数据库拷贝出错
- Android多屏滑动:ViewPager基础使用及PagerTabStrip先天缺陷(附源码)
- android processbar
- Android 使用Scroller实现绚丽的ListView左右滑动删除Item效果
- android 各国语言对应的缩写
- android中sharedPreferences的用法(转)
- android.mk说明
- Android幻灯片式图片浏览器
- android 错误之==和equals
- android的线程(Thread)和服务(Service)的区别
- Android listview与adapter用法(BaseAdapter + getView)
- 完全退出Android程序的几种方法
- android 程序更新(没有sdcard)
- Android开发文档——Notifications
- android之屏幕适配之一理论知识
- android context 获得
- Android 程式开发:(十三)特殊碎片 —— 13.2 DialogFragment