Note that there are some explanatory texts on larger screens.

plurals
  1. POWidget fails to launch properly after app has been force-stopped
    text
    copied!<p>I have a widget which launches to a particular page based on the various widget buttons pressed. It works fine when I have the app in-memory (i.e. from deploy (run / debug), however when I force stop the app, the widget no longer functions properly.</p> <p>When the app has been force stopped, the first click of the widget works properly, and the onCreate for the corresponding Activity is called. Then, when the home key is pressed, and a different widget button is pressed, the onRestart method of the previous widget Activity is called.</p> <p>It is odd, b/c the log messages do not appear, and since the debugger cannot be connected, it's been rather difficult to test. Is there anything in particular that I'm doing wrong?</p> <p>The flow is --> <em>WidgetDispatchActivity</em> (handle true widget destination) --> <em>ViewActivity</em>> --> further branch (<code>DetailViewActivity</code> in below example)</p> <p><code>onUpdate</code> for widget:</p> <pre><code>onUpdate(){ ... Intent viewIntent = new Intent(context, WidgetDispatchActivity.class); viewIntent.putExtra("launch", WidgetInfo.VIEW_ACTIVITY); PendingIntent viewPendIntent = PendingIntent.getActivity(context, 2, viewIntent, PendingIntent.FLAG_UPDATE_CURRENT); ... } </code></pre> <p>WidgetDispatchActivity's <code>onCreate</code>:</p> <pre><code> Bundle b = getIntent().getExtras(); if (b != null &amp;&amp; b.isEmpty()){ Log.i(LOG_TAG, "EMPTY BUNDLE ON WIDGET!"); }else{ Log.i(LOG_TAG, "WIDGET BUNDLE HAS ITEMS!"); } String destination = null; if (b != null &amp;&amp; b.containsKey("launch")){ destination = b.getString("launch"); Log.i(LOG_TAG, "WIDGET ITEM FROM BUNDLE WAS: " + destination); } else{ Log.i(LOG_TAG, " \"launch\" item was not inside bundle!"); } if(destination != null) { Log.i(LOG_TAG, "PendingIntent received from widget!"); Intent goTo = new Intent(this, ViewActivity.class); ... } } </code></pre> <p>LogCat</p> <pre><code>10-10 20:38:00.935: INFO/ActivityManager(58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher } 10-10 20:38:00.956: INFO/DetailViewActivity(1154): ONPAUSE 10-10 20:38:00.975: WARN/InputManagerService(58): Ignoring hideSoftInput of: com.android.internal.view.IInputMethodClient$Stub$Proxy@450366d0 10-10 20:38:02.545: INFO/ActivityManager(58): Starting activity: Intent { flg=0x10000000 cmp=com.starbucks.mobilecard/com.xxx.xxx.widget.WidgetDispatchActivity bnds=[198,298][224,321] (has extras) } 10-10 20:38:02.585: INFO/ViewActivity(1154): ONRESTART 10-10 20:38:02.585: INFO/ViewActivity(1154): WIDGET LAUNCH:: == false </code></pre> <p>ViewActivity onRestart:</p> <pre><code>protected void onRestart(){ super.onRestart(); Log.i(LOG_TAG,"ONRESTART"); Log.i(LOG_TAG,"WIDGET LAUNCH:: == " + WidgetInfo.getInstance().wasLaunchedFromWidget()); ... } </code></pre> <p>AndroidManifest:</p> <pre><code>&lt;activity android:name="com.xxx.xxx.ui.cards.ViewActivity" android:label="@string/_view_title" android:finishOnTaskLaunch="true" android:clearTaskOnLaunch="true" android:screenOrientation="portrait"/&gt; &lt;activity android:name="com.xxx.xxx.widget.WidgetDispatchActivity" android:label="@string/widget_dispatch_title" android:finishOnTaskLaunch="true"/&gt; </code></pre>
 

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