Android Open Source - Volume-Setter Widget Provider






From Project

Back to project page Volume-Setter.

License

The source code is released under:

GNU General Public License

If you think the Android project Volume-Setter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.android.volumesetter;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
import fr.android.volumesetter.R;
/*  w  ww .  j  ava 2  s . c o  m*/
public class WidgetProvider extends AppWidgetProvider {

  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager,
      int[] appWidgetIds) {

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.layout_widget);
    remoteViews.setOnClickPendingIntent(R.id.widget_image, buildButtonPendingIntent(context));
    
    pushWidgetUpdate(context, remoteViews);
  }

  public static PendingIntent buildButtonPendingIntent(Context context) {
    Intent intent = new Intent();
      intent.setAction("volumesetter.action.LOAD_CONFIG");
      return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  }

  public static void pushWidgetUpdate(Context context, RemoteViews remoteViews) {
    ComponentName myWidget = new ComponentName(context, WidgetProvider.class);
      AppWidgetManager manager = AppWidgetManager.getInstance(context);
      manager.updateAppWidget(myWidget, remoteViews);    
  }
}




Java Source Code List

fr.android.volumesetter.GlobalApp.java
fr.android.volumesetter.MainActivity.java
fr.android.volumesetter.SharedPref.java
fr.android.volumesetter.WidgetIntentReceiver.java
fr.android.volumesetter.WidgetProvider.java