Run Android app from code

I just need to run the application from my code, such as Skype, or another. I read some topic on the Internet, but I have no solution. I tried this method:

Intent startApp = new Intent("com.android.gesture.builder");
startActivity(startApp);

I wrote this in try / catch blokk and LogCat told me: ApplicationNotFound exception handled by Intent. I read the "Hello" tutorial on the Android Developers website, but it is too complicated for my solution ... I can not register the launch of this application in the manifest file. I think I need to implement a new class that extends from Activity, and implement the code above and try again? Please help me how can I launch another application from my main activity easily ...

+5
source share
1 answer

You were there !:

You just need to provide the package and class of the application you want.

// Try
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName("com.htc.Camera", "com.htc.Camera.Camera"));
startActivity(intent);
// catch not found (only works on HTC phones)

Componententame

I also saw that you can do this in a second way:

  PackageManager packageManager = getPackageManager();
  startActivity(packageManager.getLaunchIntentForPackage("com.skype.android"));

See: SOQ Ref

+3
source

All Articles