cannot override onActivityResult() method in adapter class.i got error when override this method in adapter?

package com.example.www.shayriapp.Adapter;

import android.annotation.SuppressLint; import android.app.Activity; import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Environment; import android.provider.MediaStore; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.app.AlertDialog; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast;

import com.example.www.shayriapp.Model.Shayri; import com.example.www.shayriapp.R; import com.example.www.shayriapp.Utility;

import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Date; import java.util.List; import java.util.Random;

import static android.app.Activity.RESULT_OK;

public class CustomAdapterShayri extends ArrayAdapter { Context context; Bitmap bitmap; File file; private int REQUEST_CAMERA = 1, SELECT_FILE = 1; String choosenTask; ImageView imageView; private int requestCode; private int resultCode; private Intent data;

public CustomAdapterShayri(@NonNull Context context, int resource, List<Shayri> items) {     super(context, resource, items);     this.context = context; }  class ViewHolder {     //        TextView id;     TextView sms;     //        TextView favourite; 

// TextView extra1; // TextView extra2; // TextView extra3; LinearLayout myLayout; Button btn_copy; Button btn_save; Button btn_share; Button btn_choose; }

@Override public View getDropDownView(int position, final View cnvtView, ViewGroup prnt) {     return getView(position, cnvtView, prnt); }  @NonNull @Override public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { 

// context = parent.getContext(); ViewHolder holder = null; final Shayri rowitem = getItem(position);

    if (convertView == null) {         LayoutInflater minflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);         convertView = minflater.inflate(R.layout.list_shayri, null);          holder = new ViewHolder(); 

// holder.id = (TextView) convertView.findViewById(R.id.tv_id); holder.sms = (TextView) convertView.findViewById(R.id.tv_sms); // holder.favourite = (TextView) convertView.findViewById(R.id.tv_favourite); // holder.extra1 = (TextView) convertView.findViewById(R.id.tv_extra1); // holder.extra2 = (TextView) convertView.findViewById(R.id.tv_extra2); // holder.extra3 = (TextView) convertView.findViewById(R.id.tv_extra3); // holder.linearLayout = (LinearLayout) convertView.findViewById(R.id.linearLayout); holder.myLayout = (LinearLayout) convertView.findViewById(R.id.myLayout); holder.btn_copy = (Button) convertView.findViewById(R.id.btn_copy); holder.btn_save = (Button) convertView.findViewById(R.id.btn_save); holder.btn_share = (Button) convertView.findViewById(R.id.btn_share); holder.btn_choose = (Button) convertView.findViewById(R.id.btn_choose); imageView = (ImageView) convertView.findViewById(R.id.image);

        convertView.setTag(holder);     } else {         holder = (ViewHolder) convertView.getTag();     } 

// holder.id.setText(rowitem.getId()); holder.sms.setText(rowitem.getSms()); // holder.favourite.setText(rowitem.getFavourite()); // holder.extra1.setText(rowitem.getExtra1()); // holder.extra2.setText(rowitem.getExtra2()); // holder.extra3.setText(rowitem.getExtra3());

    holder.myLayout.setLayoutParams(new ViewGroup.LayoutParams(             ViewGroup.LayoutParams.MATCH_PARENT,             ViewGroup.LayoutParams.WRAP_CONTENT));      //set background image for layout     holder.myLayout.setBackgroundResource(R.drawable.kick);      final ViewHolder finalHolder = holder;     //set background image randomly     holder.myLayout.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View view) {             //for random background images             int myImages[] = {R.drawable.nature1, R.drawable.nature2, R.drawable.nature3, R.drawable.nature4, R.drawable.nature5, R.drawable.nature6, R.drawable.nature7, R.drawable.nature8};             int rand = new Random().nextInt(myImages.length);             finalHolder.myLayout.setBackgroundResource(myImages[rand]);         }     });      holder.btn_copy.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View view) {             //For copy the text only and paste the text on paste board             ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);             ClipData clip = ClipData.newPlainText("label", rowitem.getSms());             clipboard.setPrimaryClip(clip);             Toast.makeText(context, "Copied", Toast.LENGTH_SHORT).show();         }     });     final ViewHolder finalHolder1 = holder;     holder.btn_save.setVisibility(View.VISIBLE);     holder.btn_share.setVisibility(View.VISIBLE);     holder.btn_copy.setVisibility(View.VISIBLE);     holder.btn_choose.setVisibility(View.VISIBLE);     holder.btn_save.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View view) {             saveImage(finalHolder1.myLayout);             Toast.makeText(context, "Saved", Toast.LENGTH_SHORT).show();         }          public File saveImage(LinearLayout myLayout) {             View v = myLayout;             v.setDrawingCacheEnabled(true);             v.buildDrawingCache();             finalHolder1.btn_save.setVisibility(View.GONE);             finalHolder1.btn_copy.setVisibility(View.GONE);             finalHolder1.btn_share.setVisibility(View.GONE);             finalHolder1.btn_choose.setVisibility(View.GONE);             bitmap = Bitmap.createBitmap(v.getDrawingCache());             ByteArrayOutputStream bytes = new ByteArrayOutputStream();             bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);             String imageName = "picture_" + System.currentTimeMillis() + ".jpg";             //save image in the device and make folder and save image in this folder             File folder = new File(Environment.getExternalStorageDirectory() + "/" + context.getString(R.string.app_name));             if (!folder.exists()) {                 folder.mkdir();             }             file = new File(Environment.getExternalStorageDirectory() + "/" + context.getString(R.string.app_name) + File.separator + imageName);             try {                 file.createNewFile();                 FileOutputStream fo = new FileOutputStream(file);                 fo.write(bytes.toByteArray());                 fo.close();                 finalHolder1.btn_save.setVisibility(View.VISIBLE);                 finalHolder1.btn_copy.setVisibility(View.VISIBLE);                 finalHolder1.btn_choose.setVisibility(View.VISIBLE);                 finalHolder1.btn_share.setVisibility(View.VISIBLE);             } catch (IOException e) {                 e.printStackTrace();             }             return file;         }     });     final ViewHolder finalHolder2 = holder;     final ViewHolder finalHolder3 = holder;     final ViewHolder finalHolder4 = holder;     holder.btn_share.setOnClickListener(new View.OnClickListener() {         @SuppressLint("SetTextI18n")         @Override         public void onClick(final View view) {             //open dialog box             final Dialog dialog = new Dialog(view.getContext());             dialog.setContentView(R.layout.custom);             Window window = dialog.getWindow();             WindowManager.LayoutParams wlp = window.getAttributes();             wlp.gravity = Gravity.BOTTOM;             dialog.setTitle("Sharing Option");             dialog.show();              TextView astxt = (TextView) dialog.findViewById(R.id.astxt);             astxt.setText("As Text");             TextView asimg = (TextView) dialog.findViewById(R.id.asimg);             asimg.setText("As Image");             Button btncancel = (Button) dialog.findViewById(R.id.btncancel);              btncancel.setOnClickListener(new View.OnClickListener() {                 @Override                 public void onClick(View view) {                     dialog.dismiss();                 }             });             astxt.setOnClickListener(new View.OnClickListener() {                 @Override                 public void onClick(View view) {                     //for share text only                     Intent sendIntent = new Intent();                     sendIntent.setAction(Intent.ACTION_SEND);                     sendIntent.putExtra(Intent.EXTRA_TEXT, rowitem.getSms());                     sendIntent.setType("text/plain");                     sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                     context.startActivity(sendIntent);                     dialog.dismiss();                 }             });             finalHolder3.btn_save.setVisibility(View.VISIBLE);             finalHolder3.btn_share.setVisibility(View.VISIBLE);             finalHolder3.btn_copy.setVisibility(View.VISIBLE);             finalHolder3.btn_choose.setVisibility(View.VISIBLE);             asimg.setOnClickListener(new View.OnClickListener() {                 @Override                 public void onClick(View view) {                     captureImage(finalHolder2.myLayout);                 }                  private void captureImage(LinearLayout myLayout) {                     Date now = new Date();                     try {                         String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";                         // for screenshot                         finalHolder3.btn_save.setVisibility(View.GONE);                         finalHolder3.btn_copy.setVisibility(View.GONE);                         finalHolder3.btn_share.setVisibility(View.GONE);                         finalHolder3.btn_choose.setVisibility(View.GONE);                         View v1 = myLayout;                         v1.setDrawingCacheEnabled(true);                         Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());                         v1.setDrawingCacheEnabled(false);                          File imageFile = new File(mPath);                         FileOutputStream outputStream = new FileOutputStream(imageFile);                         int quality = 100;                         bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);                         outputStream.flush();                         outputStream.close();                          finalHolder3.btn_share.setVisibility(View.VISIBLE);                         finalHolder3.btn_save.setVisibility(View.VISIBLE);                         finalHolder3.btn_copy.setVisibility(View.VISIBLE);                         finalHolder3.btn_choose.setVisibility(View.VISIBLE);                          dialog.dismiss();                         openScreenshot(imageFile);                      } catch (Throwable e) {                         e.printStackTrace();                     }                 }                  public void openScreenshot(File imageFile) {                     //for share image                     Intent intent = new Intent();                     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                     intent.setAction(Intent.ACTION_SEND);                     Uri uri = Uri.fromFile(imageFile);                     intent.setType("image/jpg");                     intent.putExtra(Intent.EXTRA_STREAM, uri);                     Intent chooserIntent = Intent.createChooser(intent, "Share Via");                     chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                     context.startActivity(chooserIntent);                 }             });         }     });      holder.btn_choose.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View v) {             selectImage();         }          private void selectImage() {             final CharSequence[] items = {"Take Photo", "Choose from Library",                     "Cancel"};              AlertDialog.Builder builder = new AlertDialog.Builder(context);             builder.setTitle("Add Photo!");             builder.setItems(items, new DialogInterface.OnClickListener() {                 @Override                 public void onClick(DialogInterface dialog, int item) {                     boolean result = Utility.checkPermission(context);                      if (items[item].equals("Take Photo")) {                         choosenTask = "Take Photo";                         if (result)                             cameraIntent();                      } else if (items[item].equals("Choose from Library")) {                         choosenTask = "Choose from Library";                         if (result)                             galleryIntent();                      } else if (items[item].equals("Cancel")) {                         dialog.dismiss();                     }                 }                  private void galleryIntent() {                     Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);                     ((Activity)context).startActivityForResult(intent,SELECT_FILE);                 }                  private void cameraIntent() {                     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);                     ((Activity)context).startActivityForResult(intent, REQUEST_CAMERA);                 }             });             builder.show();         }      });     return convertView; } ViewHolder holder;  public void onActivityResult(int requestCode, int resultCode, Intent data) {     this.requestCode = requestCode;     this.resultCode = resultCode;     this.data = data;     onActivityResult(requestCode, resultCode, data);     if (resultCode == Activity.RESULT_OK) {         if (requestCode == SELECT_FILE)             onSelectFromGalleryResult(data);         else if (requestCode == REQUEST_CAMERA)             onCaptureImageResult(data);     } } private void onCaptureImageResult(Intent data) {     Bitmap thumbnail = (Bitmap) data.getExtras().get("data");     ByteArrayOutputStream bytes = new ByteArrayOutputStream();     thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bytes);      File destination = new File(Environment.getExternalStorageDirectory(),System.currentTimeMillis() + ".jpg");     FileOutputStream fo;     try {         destination.createNewFile();         fo = new FileOutputStream(destination);         fo.write(bytes.toByteArray());         fo.close();     } catch (FileNotFoundException e) {         e.printStackTrace();     } catch (IOException e) {         e.printStackTrace();     }     Drawable d=new BitmapDrawable(context.getResources(),thumbnail);     holder.myLayout.setBackgroundDrawable(d); 

// imageView.setImageBitmap(thumbnail); } private void onSelectFromGalleryResult(Intent data) { Bitmap bm = null; if (data != null) { try { bm = MediaStore.Images.Media.getBitmap(context.getApplicationContext().getContentResolver(), data.getData()); } catch (IOException e) { e.printStackTrace(); } } Drawable d1=new BitmapDrawable(context.getResources(),bm); holder.myLayout.setBackgroundDrawable(d1); } }