从调用另一个应用程序的应用程序应用程序

2023-09-12 11:22:24 作者:╰寶貝丶亲丿迩た

在这个程序我开发我需要加载/调用的是手机上已安装其他应用程序。这是我个人的只是使用的应用程序,所以没有必要检查是否安装其他应用程序 - 我知道这是

In this app I'm developing I need to load/call another app that is already installed on the phone. It's an application for my own personal use only, so no need to check if the other app is installed - I know it is.

我GOOGLE了这个问题了几个小时,但我无法找到任何工作。这主要是因为寻找包名和类名是非常糟糕的指导方针。

I've googled this problem for hours, but I can't find anything that works. Mostly because the guidelines for finding package name and class name are really bad.

通过CMD和亚行,我能够发现关于应用程序的信息,我想呼吁的是: 包:/data/app/com.soundcloud.android-1.apk=com.soundcloud.android (这也正是它在cmd窗口说。)

Via cmd and adb I was able to find that the info regarding the application I'd like to call is: package:/data/app/com.soundcloud.android-1.apk=com.soundcloud.android (that's exactly what it said in the cmd window.)

我想是这样的:

Intent i = new Intent();
i.setClassName("/data/app/com.soundcloud.android-1.apk", "com.soundcloud.android");
startActivity(i);

但我的应用程序只是崩溃,而不是。我用上面的code,因为有人说,这可以称之为一个应用程序:

But my app just crashes instead. I used the above code because someone said that this could call an app:

Intent i = new Intent();
i.setClassName("<package_name>","<Class Name(with package name)>");
startActivity(i);

有谁知道真正写的是什么?

Does anyone know what to really write?

PS:我自己的应用程序并不需要了解所发生的事情,在被称为应用程序的任何信息

P.S.: my own app does not need any information about what's happening in the called app.

推荐答案

使用的PackageManager得到一个意向的包:

Use the PackageManager to get an Intent for the package:

PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.example.package");
startActivity(intent);