How to explicitly launch the system's Home application by c

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

How to explicitly launch the system's Home application by c

Postby lgmcben » Tue Mar 10, 2009 1:34 pm

Here's my code:

Intent i = new Intent();
i.setAction("android.intent.action.MAIN");
i.addCategory("android.intent.category.HOME");
startActivity(i);

This works well.

But actually I do have another Alternative Home application (which I
set to default for CATEGORY_HOME).

In this case, let's assume that this Alternative Home has a but in its
onCreate(), this bug cause the "Force close" screen.

The real problem is: when user set my Alternative Home as their
'default action for 'Home' ', then shutdown the device and turn it
back on. It'll keep crashing at the start up.

The user can't press back to go to system's Home app; there's no
system's Home to go back to (because my Alternative Home is the
default and is the only 'Home' loaded at boot time)

I'm sorry for my bad English. >_< What I'm trying to do is to handle
that bug(which actually only happen when user has no SD card present)
by doing this: "if there's no SD card inserted, then just launch the
System's Home app instead"

here's my code when the SD card is not found:

Intent i = new Intent();
i.setAction("android.intent.action.MAIN");
i.addCategory("android.intent.category.HOME");
startActivity(i); // this launch my Alternative Home (because it is
set as default)
lgmcben
Junior Developer
Junior Developer
 
Posts: 24
Joined: Mon Nov 17, 2008 5:06 am

Top

Postby MrSnowflake » Tue Mar 10, 2009 4:31 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Intent myIntent = new Intent();
  2.  
  3. myIntent.setClassName("com.android.launcher", "com.android.launcher.Launcher");
  4.  
  5. startActivity(myIntent);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 28 guests