从应用程序调用默认主屏幕
我需要从我的应用程序调用手机附带的默认主屏幕,这也是一个主屏幕应用程序。我尝试搜索并发现此
ArrayList<Intent> intentList = new ArrayList<Intent>();
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new
Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME),
PackageManager.MATCH_DEFAULT_ONLY)) {
intent=packageManager.getLaunchIntentForPackage(
resolveInfo.activityInfo.packageName);
intentList.add(intent);
}
代码适用于所有其他启动器,但不适用于默认启动器。我尝试在代码中使用断点,发现在列表的 0 索引处应该有默认启动器意图,但意图不保存该值。我需要某种许可吗 谢谢
I need to call the default home screen that comes with my phone from my application which is also a home screen app. I've tried searching and find this
ArrayList<Intent> intentList = new ArrayList<Intent>();
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new
Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME),
PackageManager.MATCH_DEFAULT_ONLY)) {
intent=packageManager.getLaunchIntentForPackage(
resolveInfo.activityInfo.packageName);
intentList.add(intent);
}
this code is working for the all the other launchers but not for the default launcher. I tried using break points in code and found that at 0 index of list there should be default launcher intent but intent does'nt hold the value. Do I need some kind of permission
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
希望这能行。
Hope this will do.
您可以简单地从 ResolveInfo 获取名称和类,然后像 sonyercisson 一样手动创建意图,包名称为“com.sonyericsson.home”,类为“com.sonyericsson.home.HomeActivity”,
它可以工作
you can just simple get the name and class from ResolveInfo and make intent manualy like for sonyercisson the package name is "com.sonyericsson.home" and class is "com.sonyericsson.home.HomeActivity"
it works