Android Open Source - PNC-Account-Balance P N C Widget






From Project

Back to project page PNC-Account-Balance.

License

The source code is released under:

MIT License

If you think the Android project PNC-Account-Balance 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 o.fcour.se.pncbal;
//from w  w  w  . jav a  2s .c  om
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;

public class PNCWidget extends AppWidgetProvider {

  @Override
  public void onReceive(Context c,Intent intent) {
    Log.d("PNCWidget", "Received Intent");
    if(intent.hasExtra("widget_ids")) {
      this.onUpdate(c, AppWidgetManager.getInstance(c), intent.getExtras().getIntArray("widget_ids"));
    }
    super.onReceive(c, intent);
  }

  public void onUpdate(Context c, AppWidgetManager awm, int[] widgetIds) {
    for(int id : widgetIds) {
      Log.d("PNC WIDGET", "Updating: "+id);
      RemoteViews view = new RemoteViews(c.getPackageName(),R.layout.activity_widget);
      view.setTextViewText(R.id.textView1, "$"+PNCSERVICE.getBalance());

      Intent intent = new Intent(c,Refresh.class);
      PendingIntent pendingIntent = PendingIntent.getActivity(c, 0, intent, 0);
      view.setOnClickPendingIntent(R.id.button1, pendingIntent);

      awm.updateAppWidget(id, view);
    }

    super.onUpdate(c, awm, widgetIds);
  }
}




Java Source Code List

o.fcour.se.pncbal.Config.java
o.fcour.se.pncbal.PNCSERVICE.java
o.fcour.se.pncbal.PNCWidget.java
o.fcour.se.pncbal.Refresh.java