Hi all,
i'm asking your help to understand a behaviour of my app running on JB
4.1.2.
Shortly, I want to add to my app package a widget that shows via
AdapterViewFlipper a collection of information retrived by the app (app and
widget shares the same model classes and some of the views). I tried some
methods to design this and finally I choose (any other better design hints
are welcome :) ) to separate the process of the app and that of the widget
writing the following in the manifest file:
<receiver android:name=".widget.MyApp4x1Provider"
android:label="@string/app_name"
android:process=":com.example.myapp.widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/myApp4x1info"/>
</receiver>
<service android:name=".widget.MyAppDataModelRemoteService"
android:permission="android.permission.BIND_REMOTEVIEWS"
android:exported="false"
android:process=":com.example.myapp.widget"
/>
All works fine, but this strange behaviour:
- if I only execute app all goes well, the app is executed and killed
once I remove it from the recent tasks list
- if I add the widget on my desktop all goes well, the data are shown and
refreshed how I expected
- if I open the app when the widget is active on my home all coninue to
works but when I close the app ActivityManager kills the widget process too!
Following an extract of the debug log:
[...]
(01) - 10-17 22:26:08.784: INFO/ActivityManager(306): Start proc
com.example.myapp.widget for broadcast
com.example.myapp/.widget.MyApp4x1Provider: pid=22467 uid=10066 gids={3003,
1028}
(02) - 10-17 22:26:08.963: DEBUG/com.example.myapp.MyApp(22467): onCreate
(instance: com.example.myapp.MyApp@41882800)
(03) - 10-17 22:26:08.963:
DEBUG/com.example.myapp.widget.MyApp4x1Provider(22467): onEnabled called
(wdgModelRefreshHandler: null)
(04) - 10-17 22:26:08.963:
DEBUG/com.example.myapp.widget.MyApp4x1Provider(22467): onEnabled exit
(wdgModelRefreshHandler: Handler
(com.example.myapp.widget.MyAppWidgetProvider$RefresherDaemonHandler)
{4191c6b0})
(05) - 10-17 22:26:08.971:
DEBUG/com.example.myapp.widget.MyAppWidgetProvider$RefresherDaemonHandler(22467):
REFRESHER_BEAT done for 1 widgets
(06) - 10-17 22:26:08.987:
DEBUG/com.example.myapp.widget.MyAppDataModelRemoteService(22467):
onGetViewFactory (intent:
intent:#Intent;component=com.example.myapp/.widget.MyAppDataModelRemoteService;i.appWidgetId=55;end)
(07) - 10-17 22:26:08.987:
DEBUG/com.example.myapp.core.MyAppDataModel(22467): onDataSetChanged called
[...]
(08) - 10-17 22:38:45.971: INFO/ActivityManager(306): START
{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
flg=0x10200000 cmp=com.example.myapp/.ui.Home bnds=[200,185][360,385] u=0}
from pid 593
(09) - 10-17 22:38:46.065: INFO/ActivityManager(306): Start proc
com.example.myapp for activity com.example.myapp/.ui.Home: pid=22961
uid=10066 gids={3003, 1028}
(10) - 10-17 22:38:46.284: DEBUG/com.example.myapp.MyApp(22961): onCreate
(instance: com.example.myapp.MyApp@41887670)
(11) - 10-17 22:38:46.901: INFO/ActivityManager(306): Displayed
com.example.myapp/.ui.Home: +855ms
(12) - 10-17 22:38:49.049:
DEBUG/com.example.myapp.widget.MyAppWidgetProvider$RefresherDaemonHandler(22467):
REFRESHER_BEAT done for 1 widgets
[...]
(13) - 10-17 22:38:56.706: INFO/ActivityManager(306): Killing
22467:com.example.myapp.widget/u0a66: remove task
(14) - 10-17 22:38:56.706: INFO/ActivityManager(306): Killing
22961:com.example.myapp/u0a66: remove task
(15) - 10-17 22:38:56.729: INFO/WindowState(306): WIN DEATH:
Window{4186e850 com.example.myapp/com.example.myapp.ui.Home paused=true}
(16) - 10-17 22:39:06.698: WARN/ActivityManager(306): Activity destroy
timeout for ActivityRecord{420b4b58 com.example.myapp/.ui.Home}
Where:
- the rows from (1) to (7) show that widget works properly in its own
process
- the rows from (8) to (11) show the starting of the app in a separate
process
- with the row (12) i can see that widget conintue to work if the app is
running
- the rows from (13) to (16) are when I remove the app from the recent
tasks list, and shows that, when ActivityManager kill the app process (14),
it kills the widget one too (13)
The question is, how I can avoid ActivityManager to kill both the process,
leaving that of widget alive?
Any suggestion is appreciated.
Thanks a lot and regards
Sergio
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en