Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Widget: Show configuration activity before widget is added to the screen
    primarykey
    data
    text
    <p>I have an Android Widget that uses web services to retrieve and display the data on the widget. The widget has a configuration activity that <code>extends PreferenceActivity</code>. The configuration activity starts up as soon as the widget is installed, which is the desired behavior for this widget.</p> <p>The problem is, whenever a widget is added to the home screen, the widget attempts to update iteself before the configuration activity is started/completed which may potentially lead to a long delay (several seconds). The configuration activity should occur before the widget attempts to update itself anytime a new widget is added.</p> <p>Here is the sequence of events that I'm seeing in LogCat when a widget is added:</p> <ol> <li>Widget.onRecive: action = APPWIDGET_ENABLED</li> <li>Widget.onEnabled</li> <li>Widget.onReceive: action = APPWIDGET_UPDATE</li> <li>Widget.onUpdate: Widget Service is started.</li> <li>WidgetService.onStartCommand: Potentially long running work which will delay the configuration activity from being immediately shown.</li> <li>WidgetConfiguration.onCreate</li> <li>Widget.onReceive: action = APPWIDGET_UPDATE</li> <li>Widget.onUpdate: Widget Service is started again</li> <li>WidgetService.onStartCommand: Potentially long running work is performed again.</li> </ol> <p>What's happening is that when a widget is added, the service will start up before the configuration view has been shown.</p> <p><strong>Manifest.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="xxx.xxx.xxxwidget" android:versionCode="1" android:versionName="@string/app_version" &gt; &lt;uses-sdk android:minSdkVersion="8" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;application android:debuggable="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;receiver android:name="xxxWidget" &gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info" /&gt; &lt;/receiver&gt; &lt;activity android:name="xxxWidgetConfigure" &gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;service android:name="xxxWidgetService" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p><br /><br /> <strong>Question</strong><br /> Is there a way to force the configuration activity to be shown before the system attempts to add the widget to the home screen?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload