java - App crashed when I load on the device -


i did pedometer using accelerometer. @ beginning, load in simulator in device crashed. first working until if.

this code:

 import android.app.activity;  import android.content.dialoginterface;  import android.content.pm.activityinfo;  import android.hardware.sensor;  import android.hardware.sensorevent;  import android.hardware.sensoreventlistener;  import android.hardware.sensormanager;  import android.os.bundle;  import android.os.systemclock;  import android.view.view;  import android.widget.button;  import android.widget.chronometer;  import android.widget.textview;  import java.util.list;   public class runactivity extends activity implements sensoreventlistener, view.onclicklistener {       textview x,y,z,e,l;      double x1,y1,z1, g;      private int total= 0;      private chronometer chronometer;      button start, stop;       private  sensor maccelerometer;       @override       public void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);          setcontentview(r.layout.activity_run);          x = (textview)findviewbyid(r.id.xid);          y = (textview)findviewbyid(r.id.yid);          z = (textview)findviewbyid(r.id.zid);          e = (textview)findviewbyid(r.id.count);             this.setrequestedorientation(activityinfo.screen_orientation_portrait);      chronometer = (chronometer) findviewbyid(r.id.rchronometer);     start = (button) findviewbyid(r.id.starttime);     stop = (button) findviewbyid(r.id.endtime);  }  protected void onresume()  {     super.onresume();     sensormanager sm = (sensormanager) getsystemservice(sensor_service);     list<sensor> sensors = sm.getsensorlist(sensor.type_accelerometer);      if (sensors.size() > 0)     {         sm.registerlistener(this, sensors.get(0), sensormanager.sensor_delay_game);     } } protected void onpause() {     sensormanager msensormanager=(sensormanager) getsystemservice(sensor_service);     msensormanager.unregisterlistener(this, maccelerometer);     super.onpause(); } protected void onstop() {     sensormanager msensormanager=(sensormanager) getsystemservice(sensor_service);     msensormanager.unregisterlistener(this, maccelerometer);     super.onstop(); }   @override  public void onsensorchanged(sensorevent event) {     this.x.settext("x = "+event.values[sensormanager.data_x]);     this.y.settext("y = "+event.values[sensormanager.data_y]);     this.z.settext("z = "+event.values[sensormanager.data_z]);       x1=event.values[sensormanager.data_x];     y1=event.values[sensormanager.data_y];     z1=event.values[sensormanager.data_z];      g = (math.sqrt((x1*x1)+(y1*y1)+(z1*z1)))/9.8;       if (g<1){         total++;         e.settext(total);     } } @override  public void onaccuracychanged(sensor sensor, int accuracy) {  }  @override public void onclick(view v) {     switch(v.getid()) {         case r.id.starttime:              chronometer.setbase(systemclock.elapsedrealtime());             chronometer.start();             break;         case r.id.endtime:             chronometer.stop();             break;   `  }      }  } 

also, logcat. i'm not sure happening

 e/sensormanager: exception dispatching input event.  d/androidruntime: shutting down vm  e/androidruntime: fatal exception: main                    process: com.paola.trition, pid: 6667                    android.content.res.resources$notfoundexception: string resource id #0x1 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -