android 创建shortcut
1.manifest中添加permis:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
2.创建shortcut的intent:
Intent shortcut = new Intent(
"com.android.launcher.action.INSTALL_SHORTCUT");
shortcut.putExtra("duplicate", true);
shortcut.putExtra(
Intent.EXTRA_SHORTCUT_NAME,
detail.getListing().getName());
ShortcutIconResource iconRes = Intent.ShortcutIconResource
.fromContext(
MobileProfileActivity.this,
R.drawable.mobile_android_tip_directions);
shortcut.putExtra(
Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
iconRes);
ComponentName comp = new ComponentName(
MobileProfileActivity.this.getPackageName(),
AndroidSearch.class.getCanonicalName());
Intent i = new Intent(
Intent.ACTION_MAIN);
i.putExtra(AppConstants.KEY_DIRECTIONS_LISTING_ID,
detail.getListingId());
i.setAction(AppConstants.KEY_ACTION_PIN_DIRECTIONS);
i.setComponent(comp);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,i);
sendBroadcast(shortcut);
更多相关文章
- android 备忘录之简单实现
- Android给图片添加认证水印
- Android(安卓)Wear创建通知的几种方式
- android 输入对话框
- Android中九种dialog对话框代码
- Android菜单实例
- android 图片缩放
- Android(安卓)中的 requestWindowFeature
- 在/external/tinyalsa/pcm.c 添加android log