Android,android官網
代碼
/** * * 返回添加到案頭捷徑的Intent: * * 1.給Intent指定action="com.android.launcher.INSTALL_SHORTCUT" * * 2.給定義為Intent.EXTRA_SHORTCUT_INENT的Intent設定與安裝時一致的action(必須要有) * * 3.添加許可權:com.android.launcher.permission.INSTALL_SHORTCUT */ public Intent getShortcutToDesktopIntent(Context context) { Intent intent = new Intent(); intent.setClass(context, context.getClass()); /* 以下兩句是為了在卸載應用的時候同時刪除案頭捷徑 */ intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); Intent shortcut = new Intent( "com.android.launcher.action.INSTALL_SHORTCUT"); // 不允許重建 shortcut.putExtra("duplicate", false); // 設定名字 // shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,context.getString(R.string.app_name)); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "11111"); // 設定表徵圖 shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.youtube)); // 設定意圖和捷徑關聯程式 shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); return shortcut; }
許可權
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
調用
public void click1(View v) { Intent intent = this.getShortcutToDesktopIntent(MainActivity.this); sendBroadcast(intent); }
我是天王蓋地虎的分割線
android是什
android就是機器人的意思 android手機就是使用安卓系統的手機,由Google開發出來的 和一般智能手機差不多 不知道你說的普通手機是什麼意思 android手機能夠多
android是什
android就是機器人的意思 android手機就是使用安卓系統的手機,由Google開發出來的 和一般智能手機差不多 不知道你說的普通手機是什麼意思 android手機能夠多