How to configure widget-settings by clicking on widget developer tutorial

SDK Version: 

Sometimes you need to change your widget settings after you put one to home screen. In my new tutorial I will show an easy way to solve this problem.

In your widget's xml you should set an id for the outer LinearLayout, for example "button":

  1. <LinearLayout
  2. android:id="@+id/button" xmlns:android=""  android:orientation="wrap_content" android:layout_height="wrap_content" android:layout_width="wrap_content">
  4. []
  6. </LinearLayout>

Then we declarate a new Intent that will hold our configuration activity.

Add this lines to your widget class:

  1. []
  2. public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget";
  3. []
  4. RemoteViews remoteViews;
  5. Intent configIntent = new Intent(context, WidgetControl.class);
  6.                 configIntent.setAction(ACTION_WIDGET_CONFIGURE);
  7.                 PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
  8.                 remoteViews.setOnClickPendingIntent(, configPendingIntent);
  10.                 configIntent.setAction(ACTION_WIDGET_CONFIGURE);

That's it. I hope you found this article helpful...