java - Error in Log Cat -
hi new in programming , have error in log cat. log cat shows 'fatal exception main' , application has stopped unexpectedly.i trying deal several days. application supposed show battery information
05-02 22:01:11.836: i/process(521): sending signal. pid: 521 sig: 9 05-02 22:18:54.743: d/dalvikvm(550): gc_external_alloc freed 1238 objects / 82472 bytes in 181ms 05-02 22:18:55.654: w/resourcetype(550): no package identifier when getting value resource number 0x00000032 05-02 22:18:55.664: d/androidruntime(550): shutting down vm 05-02 22:18:55.664: w/dalvikvm(550): threadid=1: thread exiting uncaught exception (group=0x4001d800) 05-02 22:18:55.744: e/androidruntime(550): fatal exception: main 05-02 22:18:55.744: e/androidruntime(550): java.lang.runtimeexception: unable resume activity {vader.batterydroid/vader.batterydroid.pageinfo}: android.content.res.resources$notfoundexception: string resource id #0x32 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythread.performresumeactivity(activitythread.java:3128) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythread.handleresumeactivity(activitythread.java:3143) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2684) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythread.access$2300(activitythread.java:125) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythread$h.handlemessage(activitythread.java:2033) 05-02 22:18:55.744: e/androidruntime(550): @ android.os.handler.dispatchmessage(handler.java:99) 05-02 22:18:55.744: e/androidruntime(550): @ android.os.looper.loop(looper.java:123) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythread.main(activitythread.java:4627) 05-02 22:18:55.744: e/androidruntime(550): @ java.lang.reflect.method.invokenative(native method) 05-02 22:18:55.744: e/androidruntime(550): @ java.lang.reflect.method.invoke(method.java:521) 05-02 22:18:55.744: e/androidruntime(550): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 05-02 22:18:55.744: e/androidruntime(550): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 05-02 22:18:55.744: e/androidruntime(550): @ dalvik.system.nativestart.main(native method) 05-02 22:18:55.744: e/androidruntime(550): caused by: android.content.res.resources$notfoundexception: string resource id #0x32 05-02 22:18:55.744: e/androidruntime(550): @ android.content.res.resources.gettext(resources.java:201) 05-02 22:18:55.744: e/androidruntime(550): @ android.widget.textview.settext(textview.java:2817) 05-02 22:18:55.744: e/androidruntime(550): @ vader.batterydroid.pageinfo.updateviews(pageinfo.java:171) 05-02 22:18:55.744: e/androidruntime(550): @ vader.batterydroid.pageinfo.updateinfo(pageinfo.java:77) 05-02 22:18:55.744: e/androidruntime(550): @ vader.batterydroid.pageinfo.access$0(pageinfo.java:74) 05-02 22:18:55.744: e/androidruntime(550): @ vader.batterydroid.pageinfo$batteryinforeceiver.onreceive(pageinfo.java:255) 05-02 22:18:55.744: e/androidruntime(550): @ vader.batterydroid.pageinfo.onresume(pageinfo.java:242) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.instrumentation.callactivityonresume(instrumentation.java:1149) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activity.performresume(activity.java:3823) 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythread.performresumeactivity(activitythread.java:3118) 05-02 22:18:55.744: e/androidruntime(550): ... 12 more
here code:
package vader.batterydroid; import android.annotation.targetapi; import android.app.activity; import android.appwidget.appwidgetmanager; import android.content.broadcastreceiver; import android.content.componentname; import android.content.context; import android.content.intent; import android.content.intentfilter; import android.content.sharedpreferences; import android.os.build; import android.os.bundle; import android.preference.preferencemanager; import android.view.view; import android.widget.button; import android.widget.imageview; import android.widget.textview; import java.util.date; public class pageinfo extends activity{ private static final boolean debug = false; private static final string not_avaiable = "----"; private static final string tag = "pageinfo"; private static final int temperature_not_available = -9999; batteryinforeceiver mbatteryir; java.text.dateformat mdf; icondrawer mdrawer; private int mhealth; private int mlevel; private sharedpreferences mpm; private int mplugged; private boolean mpresent; private int mremainingcapacity; private int mscale; private int mstatus; private string mtechnology; private int mtemperature; private long mupdatetime; private int mvoltage; private button mbtsettings; private imageview mivgraph; private textview mtvcap; private textview mtvhealth; private textview mtvlastupdate; private textview mtvplugged; private textview mtvpresent; private textview mtvstatus; private textview mtvtechnology; private textview mtvtemperature; private textview mtvvoltage; private void parseintent(intent paramintent){ this.mupdatetime = system.currenttimemillis(); this.mpresent = paramintent.getbooleanextra("present", false); this.mtechnology = paramintent.getstringextra("technology"); this.mhealth = paramintent.getintextra("health", 0); this.mstatus = paramintent.getintextra("status", 0); this.mplugged = paramintent.getintextra("plugged", 0); this.mlevel = paramintent.getintextra("level", 0); this.mscale = paramintent.getintextra("scale", 0); this.mvoltage = paramintent.getintextra("voltage", 0); this.mtemperature = paramintent.getintextra("temperature", -9999); if (this.mscale > 0){ this.mremainingcapacity = (100 * this.mlevel / this.mscale); return; } this.mremainingcapacity = this.mlevel; } private void updateinfo(context paramcontext, intent paramintent) { parseintent(paramintent); updateviews(); updatewidgetdemo(paramintent); } private void updateviews() { object localobject1; object localobject2; object localobject3; if (this.mpresent) { this.mtvpresent.settext(getresources().gettext(r.string.info_text_battery_present_yes)); if (this.mtechnology == null) this.mtvtechnology.settext(this.mtechnology); switch (this.mhealth) { default: localobject1 = "----"; this.mtvhealth.settext((charsequence)localobject1); switch (this.mstatus) { default: localobject2 = "----"; this.mtvstatus.settext((charsequence)localobject2); switch (this.mplugged) { default: localobject3 = "----"; this.mtvplugged.settext((charsequence)localobject3); if (this.mscale > 0) { this.mtvcap.settext(this.mremainingcapacity + "% (" + this.mlevel + "/" + this.mscale + ")"); this.mtvvoltage.settext(this.mvoltage + "mv"); if (this.mtemperature > -9999) break; this.mtvtemperature.settext("----"); } break; case 1: case 2: } break; case 1: case 2: case 3: case 4: case 5: } break; case 1: case 2: case 3: case 4: case 5: case 6: } } while (true) { date localdate = new date(this.mupdatetime); this.mtvlastupdate.settext(this.mdf.format(localdate)); this.mtvpresent.settext(getresources().gettext(r.string.info_text_battery_present_no)); this.mtvtechnology.settext("----"); localobject1 = getresources().gettext(r.string.info_text_battery_health_unknown); localobject1 = getresources().gettext(r.string.info_text_battery_health_good); localobject1 = getresources().gettext(r.string.info_text_battery_health_overheat); localobject1 = getresources().gettext(r.string.info_text_battery_health_dead); localobject1 = getresources().gettext(r.string.info_text_battery_health_over_voltage); localobject1 = getresources().gettext(r.string.info_text_battery_health_unspecified_failure); localobject2 = getresources().gettext(r.string.info_text_battery_status_unknown); localobject2 = getresources().gettext(r.string.info_text_battery_status_charging); localobject2 = getresources().gettext(r.string.info_text_battery_status_discharging); localobject2 = getresources().gettext(r.string.info_text_battery_status_not_charging); localobject2 = getresources().gettext(r.string.info_text_battery_status_full); localobject3 = getresources().gettext(r.string.info_text_battery_plugged_ac); localobject3 = getresources().gettext(r.string.info_text_battery_plugged_usb); this.mtvcap.settext(this.mlevel); this.mtvtemperature.settext(this.mtemperature / 10 + "°c / " + (int)((320.0f + 9.0f * this.mtemperature / 5.0f) / 10.0f) + "°f"); } } private void updatewidgetdemo(intent paramintent) { this.mdrawer.update(paramintent); this.mivgraph.setimagebitmap(this.mdrawer.drawicon(getresources().getdimensionpixelsize(r.dimen.workspaceicon_size), 1.0f)); } @targetapi(build.version_codes.cupcake) protected void oncreate(bundle parambundle) { this.mpm = preferencemanager.getdefaultsharedpreferences(getapplication()); if (integer.parseint(this.mpm.getstring("icon_style", getresources().getstring(r.string.icon_style_default))) == 0) { settheme(r.style.theme_transparent); getwindow().setflags(4, 4); setcontentview(r.layout.page_info_android); } while (true) { this.mdrawer = new icondrawer(this); this.mtvpresent = ((textview)findviewbyid(r.id.present)); this.mtvtechnology = ((textview)findviewbyid(r.id.tech)); this.mtvhealth = ((textview)findviewbyid(r.id.health)); this.mtvstatus = ((textview)findviewbyid(r.id.status)); this.mtvplugged = ((textview)findviewbyid(r.id.plugged)); this.mtvcap = ((textview)findviewbyid(r.id.cap)); this.mtvvoltage = ((textview)findviewbyid(r.id.voltage)); this.mtvtemperature = ((textview)findviewbyid(r.id.temp)); this.mivgraph = ((imageview)findviewbyid(r.id.ivgraph)); this.mtvlastupdate = ((textview)findviewbyid(r.id.tvlastupdate)); this.mbtsettings = ((button)findviewbyid(r.id.btsettings)); this.mbtsettings.setonclicklistener(new view.onclicklistener() { public void onclick(view paramanonymousview) { intent localintent = new intent(pageinfo.this.getapplicationcontext(), prefsettings.class); pageinfo.this.startactivity(localintent); } }); this.mdf = android.text.format.dateformat.gettimeformat(getbasecontext()); super.oncreate(parambundle); settheme(r.style.theme_notitle); setcontentview(r.layout.page_info); return; } } @targetapi(build.version_codes.cupcake) protected void onpause() { this.mbatteryir.unregisterreceiver(); this.mbatteryir = null; int[] arrayofint = appwidgetmanager.getinstance(this).getappwidgetids(new componentname(this, widgetprovider.class)); if ((arrayofint != null) && (arrayofint.length > 0)) { intent localintent = new intent(); localintent.putextra("appwidgetids", arrayofint); localintent.setaction(widgetprovider.force_widget_update); sendbroadcast(localintent); } super.onpause(); } protected void onresume() { if (this.mbatteryir == null) this.mbatteryir = new batteryinforeceiver(); intent localintent = this.mbatteryir.registerreceiver(); this.mbatteryir.onreceive(getapplicationcontext(), localintent); super.onresume(); } class batteryinforeceiver extends broadcastreceiver { batteryinforeceiver() { } public void onreceive(context paramcontext, intent paramintent) { if ("android.intent.action.battery_changed".equals(paramintent.getaction())) pageinfo.this.updateinfo(paramcontext, paramintent); } public intent registerreceiver() { return pageinfo.this.getapplicationcontext().registerreceiver(this, new intentfilter("android.intent.action.battery_changed")); } public void unregisterreceiver() { pageinfo.this.getapplicationcontext().unregisterreceiver(this); } } }
i thankful if me. :)
1.in eclipse, go project > clean…
2.select project, press ok
3.relaunch app
if happens again delete r.java file. generate automatically.
hope helps.
edit:-
i think somewhere in code try settext() integer value. please debug , notice this.
try, view.settext(integer.tostring(isomeinteger)) instead.
follow this link better clearity
hope helps.
Comments
Post a Comment