0

I have an Activity class inside which i have an class which extends ASynctask class where i perform parsing...everything works fine...In preexecute method of Asynctask i have set progress dialog cancellability to false through

 dialog.setCancelable(false); 

which works fine.. Now i want that if user presses Hardware back button then the that progressdialog along with loading of data should get canceled and goes back to previous activity... How can i do so?? plz help..

Keshri_raj
  • 81
  • 1
  • 8

1 Answers1

0

Now i want that if user presses Hardware back button then the that progressdialog along with loading of data should get canceled and goes back to previous activity... How can i do so??

You need to enable canceling and then override onCancelled() method. And there, just create new Intent that moves to previous Activity (or to whatever you want).

@Override
protected void onCancelled() {
   // do your stuff
}

Look here. It's useful example and a point you can start.

Community
  • 1
  • 1
Simon Dorociak
  • 33,374
  • 10
  • 68
  • 106