Android Finishing Activity Not Working
Once the user chooses a product from my ListView, it then puts the selected text from that ListView into an EditText. The problem I am having is when the user selects a product fro
Solution 1:
You need to launch your activity in a way that it doesn't get added to back stack. Here's how you do that: https://stackoverflow.com/a/12358563/375929
Solution 2:
If I understand you correctly, you are calling finish()
on the wrong Activity
. If you want the list Activity
to finish then that's where you need to call finish()
@OverridepublicvoidonItemClick(AdapterView<?> listview, View myView,
int pos, long mylng) {
StringCPU= (String) listview.getAdapter().getItem(pos);
Intenti=newIntent(getApplicationContext(),
ListmenuActivity.class);
i.putExtra("key", CPU);
startActivity(getIntent());
startActivity(i);
finish(); // finish here
}
and remove finish()
from your EditText Activity
Another issue I see is it looks like you are starting that second bit of code with the first using startActivityForResult()
but you aren't sending back a result in your second code. Instead, you seem to be starting another Activity
. It seems that second bit should be more like
@OverridepublicvoidonItemClick(AdapterView<?> listview, View myView,
int pos, long mylng) {
StringCPU= (String) listview.getAdapter().getItem(pos);
Intenti=newIntent();
i.putExtra("key", CPU);
setResult(1, i);
finish(); // finish here
}
Post a Comment for "Android Finishing Activity Not Working"