Call another activity using onPostExecute method list item click event in AsyncTask (Android) : Hello i am working on a project which populating SQLite database table for list view and using simple array adapter.

I'm using Asyntask for that purpose and i have problem when <br>
1) **i want to call another activity** and <br>
2) **pass some values which i get from the `setOnItemClickListener`**

I need to archive this two things in `onPostExecute` `setOnItemClickListener` method. This is my Code for that.

    		package com.me.doctor.doctor_me;

			import android.app.Activity;
			import android.app.Application;
			import android.content.Context;
			import android.content.Intent;
			import android.database.Cursor;
			import android.database.sqlite.SQLiteDatabase;
			import android.os.AsyncTask;
			import android.view.View;
			import android.widget.AdapterView;
			import android.widget.ListView;
			import android.widget.Toast;

			public class BackgroundTask extends AsyncTask<String,Doctor,String> {

			    Context ctx;
			    DoctorAdapter doctorAdapter;
			    Activity activity;
			    ListView listView;
			    Doctor doctor;
			    DisplayDoctor displayDoctor;

			    BackgroundTask(Context ctx){
			        this.ctx = ctx;
			        activity = (Activity) ctx;
			        doctor = new Doctor();
			        displayDoctor = new DisplayDoctor();
			    }
			    @Override
			    protected String doInBackground(String... strings) {

			        String method = strings[0];
			        DatabaseOperation databaseOperation = new DatabaseOperation(ctx);
			        if(method.equals("get_info")){
			            listView = activity.findViewById(R.id.display_list_view);
			            SQLiteDatabase db = databaseOperation.getReadableDatabase();
			            Cursor cursor = databaseOperation.getInformation(db);
			            doctorAdapter = new DoctorAdapter(ctx,R.layout.display_doctor_row);

			            String name, category, hospital;
			            int id;

			            while(cursor.moveToNext()){
			                id = cursor.getInt(cursor.getColumnIndex("d_id"));
			                name = cursor.getString(cursor.getColumnIndex("d_name"));
			                category = cursor.getString(cursor.getColumnIndex("d_category"));
			                hospital = cursor.getString(cursor.getColumnIndex("d_hospital"));
			                Doctor doctor = new Doctor(id,name,category,hospital);
			                publishProgress(doctor);
			            }
			            return "get_info";
			        }
			        return null;
			    }

			    @Override
			    protected void onProgressUpdate(Doctor... values) {
			        // add each of doctor class object add method inside the adapter class
			        doctorAdapter.add(values[0]);
			    }

			    @Override
			    protected void onPostExecute(String s) {
			        if(s.equals("get_info")){
			            listView.setAdapter(doctorAdapter);

			            listView.setOnItemClickListener(new  android.widget.AdapterView.OnItemClickListener() {
			                @Override
			                public void onItemClick(AdapterView<?> parent, View view,
			                                        final int position, long id) {

			                    Doctor doctor = (Doctor)parent.getItemAtPosition(position);
			                    String ID = Integer.toString(doctor.getId());
			                    Toast.makeText(ctx,ID,Toast.LENGTH_LONG).show();

			                    // I need fire another activity and pass some values which i getting here

			                }
			            });
			        }else{
			            Toast.makeText(ctx,s,Toast.LENGTH_LONG).show();
			        }

			    }

			}

And this is the class which call to the AsyncTask Class

    			package com.me.doctor.doctor_me;

			import android.support.v7.app.AppCompatActivity;
			import android.os.Bundle;

			public class DisplayDoctor extends AppCompatActivity {

			    @Override
			    protected void onCreate(Bundle savedInstanceState) {
			        super.onCreate(savedInstanceState);
			        setContentView(R.layout.display_doctor_layout);
			        BackgroundTask backgroundTask = new BackgroundTask(this);
			        backgroundTask.execute("get_info");
			    }

			}

Somebody can give me a solution? I had investigate close question inside here but i'm not found a solution that why put this question as new.

