Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start android application from code

I need simple start an application from my code, like Skype, or other one. I read some thread, on the internet, but I haven't solution. I tried this methode:

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

I wrote this in try/catch blokk, and the LogCat told me: ApplicationNotFound exception handled by Intent. I read the "Hello" tutorial on the Android Developers site, but it's too comlicated, to my solution... I can't register this application starting activity to my 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 start other application from my main activity easy...

like image 725
Bence Ignácz Avatar asked Aug 22 '11 10:08

Bence Ignácz


People also ask

How do I start an app from scratch?

For Android, To develop apps on the Android platform, you need to know Java or Kotlin. For those who have no clue how it works, you will need an introductory course to the programming language Java. The best place to begin is Google's Android Developer Library.


1 Answers

You were nearly there!:

You just need to supply the package and class of the app 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)

ComponentName

I also just saw you can do it a second way:

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

See: SOQ Ref

like image 198
Blundell Avatar answered Nov 15 '22 06:11

Blundell