桌面快捷方式

2021-07-23 19:58:01 字數 1382 閱讀 5626

1,(廢棄)判斷是否已經建立了快捷方式(在某些機型中需要判斷)

/**

* 判斷是否已經建立了快捷方式*

*@return*/

private

booleanhasshortcut() ,

"title=?",

newstring ,

null);

if(c !=null&& c.getcount() > 0)

public

void createshortcut()else}}

3, 刪除

*刪除桌面快捷方式

與建立相似,系統根據intent資訊進行匹配

(廢棄)

/*** 刪除程式的快捷方式*/

private

voiddelshortcut() {

intent shortcut =newintent("com.android.launcher.action.uninstall_shortcut" );

// 快捷方式的名稱

shortcut.putextra(intent. extra_shortcut_name

));.getpackagename() + "." +this.getlocalclassname();

componentname comp =newcomponentname(this

shortcut.putextra(intent. extra_shortcut_intent

,newintent(intent.action_main

).setcomponent(comp));

sendbroadcast(shortcut);

4, 宣告許可權

在androidmanifest.xml 檔案中宣告 建立和刪除快捷方式時宣告許可權

<

uses-permission

android:name="com.android.launcher.permission.install_shortcut"

/>

<

uses-permission

android:name="

com.android.launcher.permission.uninstall_shortcut

" />

建立桌面快捷方式

bool createdesktopshotcut cstring strname,在桌面顯示的名稱 cstring strsourcepath 檔案絕對路徑名稱 pshell release strdestdir.format s path strdestdir strdestdir strnam...

Android桌面快捷方式

我的應用程式會在第一次使用的時候在桌面建立乙個快捷方式,我建立快捷方式的 是這樣的 我的程式在第一次使用的時候會在桌面建立乙個快捷方式,如下 1 2 3 4 5 6 7 8 9 10 intent intent newintent intent.setclass this,splashactivit...

桌面快捷方式增 刪

我懂的,有強迫症的我們感受,正是我們孜孜不倦的去消除一切不完美的存在。拷貝一下,下面的 儲存為 x.bat x 指任何符合規則的名字定義 echo off continue echo off echo 輸入1回車新增桌面快捷方式 echo 輸入2回車刪除桌面快捷方式 echo 輸入exit回車退出,...