in my android app, I have a button that leads to an activity which in some cases, does not launch because of an if statement.
What happens, is I kill the activity with .finish(); on the onCreate, so nothing happens when the user taps the button.
But I would like to display an alert, a Toast, to the user on the current activity. Not sure if this is really clear, but here’s what should basically happen:
- User is on homepage
- User click button to go to next activity
- Nothing happens because the activity is killed with the
.finish();on the onCreate. - Here, a toast notification should be displayed on the homepage after the user clicked the button
Here’s my code so far :
try {
this.storeMarkerList = new StoreMarkerList(this.mapView);
StoreList list = (StoreList)getBaseApplication().getSessionParameter("selected.storelist", null);
if (list == null || list.size() == 0){
Toast.makeText(???, "No stores", 5000);
this.finish();
}
else {
(…)
Try this: