Android實(shí)現(xiàn)向Launcher添加快捷方式的方法
本文實(shí)例講述了Android實(shí)現(xiàn)向Launcher添加快捷方式的方法。分享給大家供大家參考。具體如下:
當(dāng)我們在應(yīng)用程序Launcher的桌面空白處長按觸摸時,會出現(xiàn)一個對話框,提示選擇要添加的桌面組件,如下圖所示

選擇快捷方式后,會彈出一個對話框,顯示出了可添加快捷方式的Activity所屬的應(yīng)用程序的圖標(biāo)和名稱的列表。當(dāng)我們想把添加快捷方式的Activity添加到這一列表時,只需要在這個Activity注冊時添加一個Action為android.intent.action.CREATE_SHORTCUT的IntentFilter就可以了。
ShortCutAction類:
package com.ljq.action;
import android.app.Activity;
import android.os.Bundle;
/**
* 向Launcher添加快捷方式
*
* @author jiqinlin
*
*/
public class ShortCutAction extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ljq.action" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon"
android:label="@string/app_name">
<activity android:name=".ShortCutAction"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
運(yùn)行結(jié)果:

希望本文所述對大家的Android程序設(shè)計有所幫助。
- 適配android7.0獲取文件的Uri的方法
- Android7.0 工具類:DiffUtil詳解
- Android7.0 MessageQueue詳解
- Android7.0上某些PopuWindow出現(xiàn)顯示位置不正確問題的解決方法
- Android開發(fā)實(shí)現(xiàn)Launcher3應(yīng)用列表修改透明背景的方法
- Android開發(fā)中Launcher3常見默認(rèn)配置修改方法總結(jié)
- Android launcher中模擬按home鍵的實(shí)現(xiàn)
- Android6.0 Launcher2應(yīng)用解析
- Android的Launcher啟動器中添加快捷方式及小部件實(shí)例
- Android7.0開發(fā)實(shí)現(xiàn)Launcher3去掉應(yīng)用抽屜的方法詳解
相關(guān)文章
Android實(shí)現(xiàn)可復(fù)用的篩選頁面
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)可復(fù)用的篩選頁面,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-06-06
Android網(wǎng)絡(luò)請求庫android-async-http介紹
這篇文章主要介紹了Android網(wǎng)絡(luò)請求庫android-async-http介紹,本文講解了android-async-http的概念、特征以及使用實(shí)例,需要的朋友可以參考下2015-06-06
Android加載html中svg格式圖片進(jìn)行顯示
這篇文章主要為大家詳細(xì)介紹了Android加載html中svg格式圖片進(jìn)行顯示,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05
Android使用webView長按保存下載網(wǎng)絡(luò)圖片
這篇文章主要為大家詳細(xì)介紹了Android使用webView長按保存下載網(wǎng)絡(luò)圖片,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-08-08
Android水波紋載入控件CircleWaterWaveView使用詳解
這篇文章主要為大家詳細(xì)介紹了Android水波紋載入控件CircleWaterWaveView使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-01-01
一文教你如何使用Databinding寫一個關(guān)注功能
這篇文章主要介紹了一文教你如何使用Databinding寫一個關(guān)注功能,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-09-09
退出Android程序時清除所有activity的實(shí)現(xiàn)方法
這篇文章主要介紹了退出Android程序時清除所有activity的實(shí)現(xiàn)方法,詳細(xì)分析了Android退出時清除activity的原理與實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-04-04

