Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication hangs up in this activity?
    primarykey
    data
    text
    <pre><code> public class JobStartedScreen extends Activity implements OnMessageReceived{ TextView tv_JobNo; static TextView tv_JobKm; static TextView tv_speed; static TextView tv_JobwaitngTime; TextView tvjobstartedtime; Button btn_jobFinsh; Button btn_msg; ImageButton navig; boolean _ThreadFlag=false; boolean _ResumeThread=false; private Window w; Thread t=null; String jobno; String tag="Jobstartscreen"; private static MyThread sThread; static TextView tv_Fare; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.jobstartedscreen); if (savedInstanceState==null){ Contsants.VehicleStartOdometer=0.0F; sThread=new MyThread(mHandler); sThread.start(); } tcpSocket.setmMessageListener(this); tv_JobNo =(TextView)findViewById(R.id.tvJobid); Bundle bundle = getIntent().getExtras(); jobno= bundle.get("Jobno").toString(); tv_JobNo.setText(jobno); tv_JobKm =(TextView)findViewById(R.id.tvjobKm); tv_JobwaitngTime =(TextView)findViewById(R.id.tvjobWaittime); tv_speed=(TextView)findViewById(R.id.speed); tv_Fare=(TextView)findViewById(R.id.tv_fare); tv_JobwaitngTime.setText("Waiting Time : 0:0"); //update the Km every 1 sec Log.d(tag, "On created "+_ResumeThread); tvjobstartedtime=(TextView)findViewById(R.id.tv_jobStarttime); tvjobstartedtime.setText("Start Time :"+Contsants.jobStartTime); btn_jobFinsh= (Button)findViewById(R.id.btn_jobFinsh); btn_jobFinsh.setOnClickListener(onClickListener); btn_msg= (Button)findViewById(R.id.btn_msg); btn_msg.setOnClickListener(onClickListener); StateManager.DeviceStatus=StateManager.hired; // TODO Auto-generated method stub } @Override public void onStart() { super.onStart(); } @Override public void onResume() { super.onResume(); w = this.getWindow(); w.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD); w.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED); w.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON); Log.d("job start on resume",_ThreadFlag+" "+_ResumeThread); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState){ super.onRestoreInstanceState(savedInstanceState); if (sThread.isAlive()){ sThread.setHandler(mHandler); } } @Override protected void onDestroy(){ super.onDestroy(); if (sThread.isAlive()){ sThread.setHandler(null); } sThread.setHandler(null); } boolean _Paused=false; @Override public void onPause() { super.onPause(); _Paused=true; } @Override public void onBackPressed() { // do nothing. } private OnClickListener onClickListener = new OnClickListener() { @Override public void onClick(final View v) { switch(v.getId()){ case R.id.btn_jobFinsh: //DO something _ThreadFlag=true; StateManager.JobStatus=StateManager.jobstatus_dropped; tcpSocket.SendMessage(FramePacket.FrameJobStatusCmd(Contsants.Jobno,StateManager.JobStatus)); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy HH:mm"); String currentDateandTime = sdf.format(new Date()); Contsants.jobEndTime=currentDateandTime; Contsants.jobEndKm =gpsdataElements.Distance; Intent i = new Intent(getApplicationContext(),JobCompletionScreen.class); startActivity(i); sThread.setHandler(null); finish(); break; case R.id.btn_msg: Intent imsg = new Intent(getApplicationContext(),MessageList.class); startActivity(imsg); break; } } }; static Handler mHandler =new Handler(){ @Override public void handleMessage(Message message){ //update UI Bundle b = message.getData(); float odometer = b.getFloat("My Odometer"); String Fare = b.getString("Fare"); int waiting =b.getInt("waiting Time"); double speedVal= b.getDouble("SpeedValue"); tv_speed.setText(String.format("%.2f",speedVal)+" Km/hr"); tv_JobKm.setText(String.format("%.2f",odometer)+" Km"); tv_Fare.setText(Fare); tv_JobwaitngTime.setText(Integer.toString((waiting / 60)) +":"+ Integer.toString((waiting% 60))); Contsants.jobTotalwaitingTime=Integer.toString((waiting / 60)) +":"+ Integer.toString((waiting% 60)); } }; private class MyThread extends Thread{ private Handler mHandler; public MyThread(Handler handler){ super(); mHandler=handler; } @Override public void run(){ //some long operation if (mHandler!=null) mHandler.sendEmptyMessage(0); _ResumeThread=true; while(!_ThreadFlag) { try { Thread.sleep(1000); Message msg = new Message(); Bundle b = new Bundle(); b.putFloat("My Odometer", (float) (gpsdataElements.Distance-Contsants.jobStartKm)); if(gpsdataElements.Speed&lt;1) { Contsants.cont_WaitingTimeInSec++; } float totalKm = Contsants.jobEndKm-Contsants.jobStartKm ; if (totalKm&lt;Contsants.minDist) { float totalfare=Contsants.minFare; b.putString("Fare", String.format("%.2f",(totalfare))); } else { float totalfare= Contsants.minFare+ ((totalKm-Contsants.minDist) *Contsants.rupeeKm) +(Contsants.cont_WaitingTimeInSec/60)*1; b.putString("Fare", String.format("%.2f",(totalfare))); } b.putInt("waiting Time", Contsants.cont_WaitingTimeInSec); b.putDouble("SpeedValue", gpsdataElements.Speed*1.852); // tv_JobwaitngTime.setText("Waiting Time : "+Integer.toString((Contsants.cont_WaitingTimeInSec / 60)) +":"+ Integer.toString((Contsants.cont_WaitingTimeInSec % 60))); //send message to the handler with the current message handler msg.setData(b); // send message to the handler with the current message handler mHandler.sendMessage(msg); } catch (Exception e) { Log.v("Error", e.toString()); } } } public void setHandler(Handler handler){ mHandler=handler; } } @Override public void messageReceived(String message) { // TODO Auto-generated method stub //Toast.makeText(getApplicationContext(), "Job StartScreem : Recived data :"+message, Toast.LENGTH_LONG).show(); } } </code></pre> <p>this activity was hangs up while in moving condition. I was tried to test this app. but during this JobstartedScreen activity it hangs up sometime and shows me a error foreclose or wait message. if i click wait option means its value was suddenly changed. i dont know why this error came. I think it was due to else condition part calculation. but i dont know definitely. if anyone know help me guys.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload