I have created an AppWidget for Honeycomb which is working well, except that when first installed, it does not show up in the Widgets menu so it can not be added to a home screen. Rebooting the device will allow it to show up, or during development, sending it twice from Eclipse will cause it to show up.
Any ideas?
Thanks!
Appearently EboMike was right, setting android:installLocation="internalOnly" did fix the issue. Without specifying an install location, it should have defaulted to internalOnly, but did not seem to for me. Perhaps something changed in Honeycomb?
Also, even with internalOnly set, I was still seeing the issue when installing from Eclipse (widget would not show up in the selection menu until the second run) but when installing from the android market, it seems to be working fine which was my major concern.
Thanks!
The reason for this is actually described here and it is by design as of Android 3.1. By default, the installLocation will already be set to "internalOnly" so that should not fix the problem and neither should a reboot.
To work around this, an activity needs to be triggered in your widget. This will activate it and it will then appear in the widget list.
To do this, you can add an activity that essentially does nothing like this:
1) In your AndroidManifest.xml, add this inside your "application" tag:
<activity
android:name=".DummyActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
2) Then create a "DummyActivity.java" class in your "src" like this:
package com.domain.app;
import android.app.Activity;
import android.os.Bundle;
public class DummyActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
finish();
}
}
Now, when you deploy the widget to your device, that activity will be launched automatically (you'll see a message in your Eclipse console saying "starting activity ...") and it will immediately "finish" without showing anything visual on the device. And now your widget will be listed in the widget list!
Spooky,
I did this installLocation fix and it worked first time.
But from then on I still have to reboot every time I update my widget on my Xoom with 3.01 to see it in the list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With