java - Adding battery percentage to my widget -


I am building a widget for the homescreen, now I've took it, I add the percentage of battery How can I do this?

Public Class Halovijet extends AppWidgetProvider {

  @ Override public void update (REFERENCES, AppWidgetManager appWidgetManager, int [] appWidgetIds) {Timer timer = new Timer (); Timer.scheduleAtFixedRate (New MyTime (Reference, App Adam's Manager), 1, 1000); } Private class MyTime TimerTask extended {RemoteViews remoteViews; AppWidgetManager appWidgetManager; Component this widget; Dinankformet format = Srldetaformetkget time Instens (Srldetaformet.amdiaim, Lokelkget default ()); Public MyTime (context reference, AppWidth Manager AppWith Guide) {this.appWidgetManager = appWidgetManager; RemoteViews = New Remote Power (context.getPackageName (), R.Lay Out.man); ThisWidget = new element name (reference, HelloWidget.class); } @ Override public void run () {remoteViews.setTextViewText (R.id.widget_textview, format.format (new Date ())); AppWidgetManager.updateAppWidget (this widget, remote view); }}  

}

Is this my main Java file, any way to add percentages?

I tried to do this

  Personal TextView BatteryText; Private broadcast receiver mBatInfoReceiver = new broadcast receiver () {@ Override public Ricoid on Risev (reference Sitiaksti, intent intent) {int level = intent.getIntExtra (BatteryManager.EXTRA_LEVEL, 0); BatteryTxt.setText (string.valof (level) + "%"); }}; Override public null at @Critt (bundle B) {super. Content (B); SetContentView (R.layout.main); ContentTxt = (TextView) this.findViewById (RID Batterytext); this. Registry receiver (Yh.ambiattinfoisevr new Intentfiltr (intent. Akshn_ BATTERY_CHANGED)); }}  

But I can not but it is correct, please help


Comments