How to explicitly launch the system's Home application by code?

by Kakyoin » Tue, 10 Mar 2009 20:21:05 GMT


Sponsored Links
 Topic.  Short and sweet question. And I did browse the forum before
asking.

Thank you in advance.
--~--~---------~--~----~------------~-------~--~----~



How to explicitly launch the system's Home application by code?

by Kakyoin » Tue, 10 Mar 2009 20:59:41 GMT


 




Hi. Thank you for the reply.

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)

Anyway, Thank you for your reply. =)
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


How to explicitly launch the system's Home application by code?

by MrSnowflake » Wed, 11 Mar 2009 02:40:23 GMT


 As I said on Anddev.org earlier:
Intent myIntent = new Intent();
myIntent.setClassName("com.android.launcher",
"com.android.launcher.Launcher");
startActivity(myIntent);






--~--~---------~--~----~------------~-------~--~----~



How to explicitly launch the system's Home application by code?

by MrSnowflake » Wed, 11 Mar 2009 02:41:35 GMT


 I have to say, I don't think this method will keep working in future
versions as the package and class name of the launcher might change!







--~--~---------~--~----~------------~-------~--~----~



How to explicitly launch the system's Home application by code?

by Kakyoin » Wed, 11 Mar 2009 13:53:48 GMT


 Hi. Thank you all for the answers.

Launching by class name was very helpful for now but following your
advice, I'll not use that method. >_<


--~--~---------~--~----~------------~-------~--~----~



How to explicitly launch the system's Home application by code?

by MrSnowflake » Wed, 11 Mar 2009 21:26:49 GMT


 ut using CATEGORY_HOME won't solve his problem.

On 10 mrt, 19:41, Romain Guy <romain...@google.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



How to explicitly launch the system's Home application by code?

by MrSnowflake » Thu, 12 Mar 2009 05:22:14 GMT


 ice, thanks!

On 11 mrt, 19:14, Dianne Hackborn <hack...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Spinner gets error when drop down

I want the spinner displays ImageView+TextView, so I create two
classes as below:
    public class AlbumSpinnerItem extends LinearLayout {
        private ImageView mAlbumType;
        private TextView mAlbumName;

        public AlbumSpinnerItem(Context context, String text, int
resourceId) {
            super(context);

            this.setOrientation(HORIZONTAL);

            this.mAlbumType = new ImageView(context);
            this.mAlbumType.setImageResource(resourceId);

            this.mAlbumName = new TextView(context);
            this.mAlbumName.setText(text);

            // Add child views to this object
            LinearLayout.LayoutParams param1 = new
LinearLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
            param1.gravity = Gravity.LEFT;
            this.addView(this.mAlbumType, param1);

            LinearLayout.LayoutParams param2 = new
LinearLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
            param2.gravity = Gravity.RIGHT;
            this.addView(this.mAlbumName, param2);
        }
    }

    public class AlbumSpinnerAdapter extends
ArrayAdapter<AlbumSpinnerItem> {
        Context c;
        List<AlbumSpinnerItem> s;

                public AlbumSpinnerAdapter(Context context, int 
textViewResourceId,
                                List<AlbumSpinnerItem> objects) {
                        super(context, textViewResourceId, objects);
                        c = context;
                        s = objects;
                }

                @Override
                public View getDropDownView(int position, View convertView,
                                ViewGroup parent) {
                        if (position<s.size())
                                return s.get(position);
                        else
                                return null;
                }

                @Override
                public View getView(int position, View convertView, ViewGroup
parent) {
                        if (position<s.size())
                                return s.get(position);
                        else
                                return null;
                }

                @Override
                public int getCount() {
                        return s.size();
                }
    }

But I get the following error information:
10-07 16:25:42.253: ERROR/AndroidRuntime(1146): Uncaught handler:
thread main exiting due to uncaught exception
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.ListView.measureHeightOfChildren(ListView.java:1104)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.ListView.onMeasure(ListView.java:1045)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.View.measure(View.java:6621)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:
890)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.LinearLayout.measureVertical(LinearLayout.java:347)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.LinearLayout.onMeasure(LinearLayout.java:275)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.View.measure(View.java:6621)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:
890)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.LinearLayout.measureVertical(LinearLayout.java:347)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.LinearLayout.onMeasure(LinearLayout.java:275)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.View.measure(View.java:6621)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.FrameLayout.onMeasure(FrameLayout.java:208)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.View.measure(View.java:6621)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.widget.FrameLayout.onMeasure(FrameLayout.java:208)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.View.measure(View.java:6621)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.ViewRoot.performTraversals(ViewRoot.java:620)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1103)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.os.Handler.dispatchMessage(Handler.java:88)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.os.Looper.loop(Looper.java:123)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
android.app.ActivityThread.main(ActivityThread.java:3742)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
java.lang.reflect.Method.invokeNative(Native Method)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
java.lang.reflect.Method.invoke(Method.java:515)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:739)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
10-07 16:25:42.321: ERROR/AndroidRuntime(1146):     at
dalvik.system.NativeStart.main(Native Method)

--~--~---------~--~----~------------~-------~--~----~

2. problem installing updates for ADT

Hi

I am getting problems installing the updates of the ADT plugin. Tried
all the methods suggested in the wiki but keep getting the message "No
features found on the selected site". Please help me out.

Regards

--~--~---------~--~----~------------~-------~--~----~

3. Hello, Please help me get back into the developer group discussion board

4. Emulator crashes X on Ubuntu 8.4

5. View after ListView does not show up

6. Lunar Lander IllegalThreadStateException

7. how to download and install applications on android phone