I have an application with two activies. First one is reading serial data from arduino using asynctask. When button is clicked on first activity it should start second activity. But when I click that button it's going to android launcher everytime. Meanwhile second activity also opened in background.
I don't understand why android launcher is opening but not showing second activity on screen. Any suggestions? Thanks.
private class AdkReadTask extends AsyncTask<Void, String, Void> {
public void pause() {
degisken = false;
}
@Override
protected Void doInBackground(Void... arg0) {
while (degisken) {
publishProgress(mAdkManager.readSerial());
SystemClock.sleep(50);
}
return null;
}
protected void onProgressUpdate(String... progress) {
kapak2 = (int) progress[0].charAt(2);
kapak1 = (int) progress[0].charAt(1);
limit = (int) progress[0].charAt(0);
tx5.setText("kapak1 : " + (int) progress[0].charAt(1)
+ " kapak2 : " + (int) progress[0].charAt(2) + " limit : "
+ (int) progress[0].charAt(0));
}
}
public void butonClick(View v) {
Intent intent = new Intent(UDOOBlinkLEDActivity.this,
shortcuts.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("dil", dil);
startActivity(intent);
}
Change this.
Intent intent = new Intent(UDOOBlinkLEDActivity.this,
shortcuts.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(intent); remove this line
intent.putExtra("dil", dil);
startActivity(intent);
Because twice you are calling startActivity(intent);
and after that you are sending data and again startActivity. So problem occurs.