如何获得的发现,在主屏幕发射android系统中安装的所有快捷键列表 [英] How to get the list of all installed shortcuts found in the homescreen Launcher in android

查看:209
本文介绍了如何获得的发现,在主屏幕发射android系统中安装的所有快捷键列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得所有已安装的快捷键列表中的主屏幕发射器编程。 我发现很多片段在网上,但他们没有提供正确的输出

I wanted to get the list of all installed shortcuts in the homescreen launcher programmatically. I have found lots of snippets online but none of them provides the right output

这个片断:

Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
ArrayList<Intent> intentList = new ArrayList<Intent>();
Intent intent=null;
String launchers="";
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(shortcutsIntent,   0)) {
launchers=launchers+"\n"+resolveInfo.activityInfo.packageName;
intent=packageManager
         .getLaunchIntentForPackage(resolveInfo.activityInfo.packageName);
intentList.add(intent);    
}

这只是提供如联系人,浏览器等方面的preset的快捷方式。不正是在主屏幕中。

this only provides the preset shortcuts like contacts, browsers,etc. not exactly what is found in the homescreen.

而这个片段:

    PackageManager pm = getPackageManager();
    Intent i = new Intent("android.intent.action.MAIN");
    i.addCategory("android.intent.category.HOME");
    List<ResolveInfo> lst = pm.queryIntentActivities(i, 0);
    if (lst != null) {
       for (ResolveInfo resolveInfo : lst) {  
           }
       }
    }

仅提供了默认的启动是com.android.launcher。

only provides the default launcher which is com.android.launcher.

推荐答案

我的回答可能会迟到,但也可能是为别人有用。

My answer may be late, but it might be useful for others.

检查我的code:

if (Build.VERSION.SDK_INT <8) 
{ 
url = "content://com.android.launcher.settings/favorites?Notify=true"; 
} 
else 
{ 
url = "content://com.android.launcher2.settings/favorites?Notify=true"; 
} 

ContentResolver resolver = getContentResolver(); 
Cursor cursor = resolver.query (Uri.parse(url), null, null, null, null);

这篇关于如何获得的发现,在主屏幕发射android系统中安装的所有快捷键列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆