查找系统应用程序的包和活动名称?

发布于 2024-11-29 16:23:11 字数 148 浏览 3 评论 0原文

我如何在 motoblur 和 touchwiz 上查找系统应用程序的包名称和主要活动名称?我正在制作一个应用程序,但我希望它是通用的,而不仅仅是 Sense 和普通 android。我实际上并没有运行 touchwiz 或 motoblur 的手机,所以我不知道如何找到它们。谢谢

How would I go about finding the package names and main activity name for system apps on motoblur and touchwiz? I am making an app but I want it to be universal, not just Sense and stock android. I dont actually own a phone running touchwiz or motoblur so I am stumped on how to find them out. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伪装你 2024-12-06 16:23:11

请注意,您不应该通过包/类名称启动活动 - 系统应用程序因设备而异,并且活动类名称可能会随着应用程序更新而改变(我注意到 Google 地图曾经这样做过)。

另一个原因是用户可能更喜欢使用他们安装的其他应用程序来执行特定任务(例如我更喜欢使用第 3 方应用程序拍照)。

您应该通过系统定义的意图来调用应用程序。

Note that you should not start activities via package/class names - system apps vary from device to device AND activity class names might change with app updates (I noticed Google Maps did this once).

The other reason would be that users might prefer to use some other app they installed to do particular task (for example I prefer to take pictures with a 3rd party app).

You should invoke apps via system defined intents.

ι不睡觉的鱼゛ 2024-12-06 16:23:11

您需要收集有关手机上已安装应用程序的信息,然后浏览列表并搜索所需的活动

   PackageManager packmngr = this.getPackageManager(); 
    Intent ints = new Intent(Intent.ACTION_MAIN, null)
    ints.addCategory(Intent.CATEGORY_LAUNCHER); 
    List<ResolveInfo> list = packmngr.queryIntentActivities(ints, PackageManager.PERMISSION_GRANTED); 

ints.addCategory(Intent.CATEGORY_LAUNCHER); <--- 这里您可以指定使用查询搜索的 Intent 类型(清单中定义的其他应用程序的开发人员),可以通过 CATEGORY_LAUNCHERCATEGORY_DEFAULT,实际上主要活动的类型是CATEGORY_LAUNCHER

以及列表中的简单迭代:

       for(ResolveInfo rlnfo: list)
        {
             //Adjust the code and do tests within here.
            Log.i("ACTIVITY INFO: ", rlnfo.activityInfo.toString());
            Log.i("ACTIVITY NAME: ",rlnfo.resolvePackageName.toString());
        }

在此处查看有关常量和方法的更多信息:
http://developer.android.com/reference/android/content/pm /PackageManager.html

You need to gather info about installed apps on the phone than go through the list and search for desired activity

   PackageManager packmngr = this.getPackageManager(); 
    Intent ints = new Intent(Intent.ACTION_MAIN, null)
    ints.addCategory(Intent.CATEGORY_LAUNCHER); 
    List<ResolveInfo> list = packmngr.queryIntentActivities(ints, PackageManager.PERMISSION_GRANTED); 

ints.addCategory(Intent.CATEGORY_LAUNCHER); <--- Here you can specify what type of Intent (which the developer of the other app defined in the manifest) to search with the query, it can by either CATEGORY_LAUNCHER or CATEGORY_DEFAULT, actually the main activities are of type CATEGORY_LAUNCHER.

And the trivial iteration in the list:

       for(ResolveInfo rlnfo: list)
        {
             //Adjust the code and do tests within here.
            Log.i("ACTIVITY INFO: ", rlnfo.activityInfo.toString());
            Log.i("ACTIVITY NAME: ",rlnfo.resolvePackageName.toString());
        }

Check here for more info about constants and methods:
http://developer.android.com/reference/android/content/pm/PackageManager.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文