I am using AsyncTask to convert an image to a base64 value. The task runs in the background and the application proceeds to the next step. How can I check the status of AsyncTask to check if it is complete or not ...
My asynthetic code ...
public class Asyncimg extends AsyncTask<Void, Integer, String> { //for converting images to base64 protected void onPreExecute (){ //disbaling sync button on converting pic to base64 } protected String doInBackground(Void...arg0) { Cursor cursor = mydb.getDat1(); //fetching the image location cursor.moveToFirst(); while (!cursor.isAfterLast()) { for( int i=0 ; i< 1 ; i++ ) { if( cursor.getColumnName(i) != null ) { try { if( cursor.getString(i) != null ) { //saving image to bitmap Bitmap bitmap = BitmapFactory.decodeFile(cursor.getString(cursor.getColumnIndex(DBHelper.PHOTO))); //converting it to base64 String en= encodeToBase64( resize(bitmap,1080,1920), Bitmap.CompressFormat.JPEG,50); Log.d("base",en); //inserting it to table pic mydb.insertpic(cursor.getInt(1),en); } } catch( Exception ignored) { } } } cursor.moveToNext(); } cursor.close(); mydb.updatebin(); return null; } protected void onPostExecute(String result) { } }
How can I check his status from another action.?
user7315434
source share