starting Launcher app from my own application

Put your problem here if it does not fit any of the other categories.

starting Launcher app from my own application

Postby MissG » Thu Nov 11, 2010 1:53 pm

I got an application, which stats as main activity when my andorid OS get start. I set it doe default launch-activity. now i wanna press a button in my application to start the default launcher app "com.android.launcher", when i press a button.

Do i have to do ist with an intent like this code?:

Code: Select all
       final Intent launcherIntent = new Intent(Intent.ACTION_MAIN, null);
              launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                final ComponentName cn = new ComponentName("com.android.launcher", "com.android.launcher");
                launcherIntent.setComponent(cn);
                launcherIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(launcherIntent);


I try this, but i got an error...

does anyone got a better idea?
MissG
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Nov 04, 2010 12:08 pm

Top

Re: starting Launcher app from my own application

Postby Schermvlieger » Thu Nov 11, 2010 3:30 pm

Hi MissG,

Thy this:

Code: Select all
Intent homeintent = new Intent();
homeintent.setAction(Intent.ACTION_MAIN);
homeintent.addCategory(Intent.CATEGORY_HOME);
homeintent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(homeintent);


If your app is also a HOME application you have to make sure yours is not the "default" HOME application, before you raise this intent. You can do that with the following line of code;

Code: Select all
getApplicationContext().getPackageManager().clearPackagePreferredActivities(getPackageName());
Schermvlieger
Senior Developer
Senior Developer
 
Posts: 159
Joined: Fri Feb 26, 2010 1:37 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests