android - How to save the configuration of widgets -
I am busy in the following
Especially in that part where you set up a < p> I need help with 2: gin People have goggleed me from people But how do I get the preference now? I am using a service to update my widget. Can I get them in the MyWidgetProvider? My current migration provider: widget And allows it to modify the App Widget Settings at the time In the mode you can set an update frequency, text in the TextView, to create background background and so on ... This means that you are setting up the widget before setting up and being visible. You can save all the codes in If you need more details then Please ask. ConfigurationActivty
AppWidgetManager by calling
AppWidgetManager.getInstance ()
Remote Veez layout
make intentions < / Code>, set it with the
activity result, and end the
activity
SharedPrefs , but how can I actually use my XML, which gives information about the widget, such as the update frequency:
& lt ;? xml version = "1.0" encoding = "UTF-8" & gt; & Lt; Appwidget-provider xmlns: android = "http://schemas.android.com/apk/res/android" Android: initialLayout = "@ layout / widget_layout" Android: minHeight = "200dp" Android: minWidth = "144dp" Android: WidgetCategory = "home_screen" Android: configure = "widget.AppWidgetConfigureActivity" Android: updatePeriodMillis = "1800000" & gt; & Lt; / appwidget provider & gt; {Edit:} OK I have implemented it yet:
Private Zero Navigation Configuration () {int deviceTypeId = 0; Int deviceId = 0; String hashed pasCode = ""; Int updateFreq = 30000; Shared references prefs = AppWidgetConfigureActivity.this.getSharedPreferences ("prefs", 0); Edit SharedPreferences.Editor = prefs.edit (); Edit.putInt ("Widget_DeviceTypeId:" + appWidgetId, deviceTypeId); Edit.putLong ("Widget_DeviceId:" + appWidgetId, deviceId); Edit.putString ("Widget_Passcode:" + appWidgetId, hashed pseudoded); Edit.putInt ("Widget_UpdateFreq:" + appWidgetId, updateFreq); edit.commit (); }
The public class expands MyWidgetProvider AppWidgetProvider {Personal Static Last String Log = "de.vogella.android.widget.example" "@Update Override public null (Reference Reference, AppWidgetManager appWidgetManager, int [] appWidgetIds) {Log.w (Log, "called Aparicated Method"); // Get All IDs Components- thisWidget = New Component Name (Reference, MyWidgetProvider Class); int [] allWidgetIds = appWidgetManager.getAppWidgetIds (thisWidget); // Get Preferences: // Service Intent Intent = New Intent Intention to call .getApplicationContext (), UpdateWidgetService.class; Update Widgets through the context of Intent.putExtra (AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds); // Service. Initial Service (Intent);} App Widget Configuration Activity A The optional activity that a user connects to your app, launches.
shared contexts and if you need to update or rebuild the widget (after reboot or configuration changes), you
shared references to <> UPDATE your
AppWidgetProvider or
UpdateWidgetService.java in your service. Since you use
UpdateWidgetService to update your code, you should use
SharedPreferences in this service
Here's an example:
context reference = getApplicationContext (); Shared references prefs = context.getSharedPreferences ("prefs", 0); Int deviceTypeId = prefs.getInt ("Widget_DeviceTypeId:" + appWidgetId, defValue); // defValue is used if preference does not exist / get all other preferences / settings and use them to update widget
Comments
Post a Comment