Android,android官網

來源:互聯網
上載者:User

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手機能夠多
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.