I'm a little confused about in which process an App Widget is running by default. Over at Android Developers i read:
"Every application runs in its own process and all components of the application run in that process, by default" - From: http://developer.android.com/guide/components/processes-and-threads.html
My textbook says:
"Android App Widgets do not run in the application process, but in the host’s process. Therefore, the App Widget uses the RemoteViews class to define its user interface.The RemoteViews class supports a subset of the overall View hierarchy, for display in another process. Generally speaking, you want to configure the RemoteViews object and send it to the App Widget Manager during the onUpdate() method. However, you also need to update it when an instance is created and a configuration activity exists." From: Android Wireless Application Development Volume II 3rd Edition, page 370
Someone also asked this question before and the answer is "same process": Does an android widget run in the same process as it's app
Can someone please help me understand if an Android App Widget runs in its own process or in the same as the main applikation. Thanks
That depends on what you think an "Android App Widget" actually is:
If you think that an app widget is a bit of UI that runs on the home screen, that UI is being rendered by the home screen's process.
If you think that an app widget is a subclass of AppWidgetProvider, then that runs in your own app's process.
The app widget system is a plugin mechanism. The home screen, with the assistance of the Android framework, requests RemoteViews objects from the AppWidgetProvider. Those RemoteViews represent the UI to be rendered by the home screen. However, the work to create that RemoteViews will be in your process, as with any other of your app components. And usually the work to process click events will route to your process via a PendingIntent.
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