com.lampa.startapp icon indicating copy to clipboard operation
com.lampa.startapp copied to clipboard

Different results when using package param to start app

Open StepM1997 opened this issue 3 years ago • 7 comments

I have an old application which use package name to check app and start app. I found that some apps can be started with package and some are not. For example,

In App A, I check the app is installed in the device and start app is succeeded. In App B, I also check the app is installed but cannot start app and receive android.content.ActiveityNotFoundException: No Activity found to handle Intent ( package name }.

Although I am able to use application and intentstart to start app, what is the reason of above problem?

StepM1997 avatar Sep 28 '20 04:09 StepM1997

@StephenMok1997 Hmm, if you use package for start app, you need add to command name of activity or action because package its not a intent for start app, its only package name. And that to start app with package name, we need to add action with this package, exam:

var sApp = startApp.set({
	"action":"ACTION_MAIN",
	"package":"com.lampa.startapp"
});

But if we need only start app with package name, without action or activity, we need to use parameter application:

var sApp = startApp.set({
	"application":"com.application.name"
}).start();

lampaa avatar Sep 29 '20 07:09 lampaa

So any possible reason that some app can start and some app cannot?

StepM1997 avatar Sep 29 '20 08:09 StepM1997

@StephenMok1997 error indicates that the main activity not found in the application (perhaps for <action android: name = "android.intent.action.MAIN" />)! Does the application open through the device interface?

lampaa avatar Sep 29 '20 09:09 lampaa

What do you mean by device interface?

StepM1997 avatar Oct 05 '20 02:10 StepM1997

What do you mean by device interface?

Android Launcher

lampaa avatar Oct 05 '20 07:10 lampaa

@StephenMok1997 error indicates that the main activity not found in the application (perhaps for <action android: name = "android.intent.action.MAIN" />)! Does the application open through the device interface?

No

StepM1997 avatar Oct 05 '20 07:10 StepM1997

@StephenMok1997 error indicates that the main activity not found in the application (perhaps for <action android: name = "android.intent.action.MAIN" />)! Does the application open through the device interface?

No

So you need to get the package name and the activity name of application for start application, example:

var sApp = startApp.set({
	"component": ["com.app.name","com.app.name.QrScannerActivity"]
}).start();

You can get package name and activity name by decompiling application and looking at its AndroidManifest.xml 👀🤷

lampaa avatar Oct 05 '20 08:10 lampaa