title: How to call camera intent in CustomAdapter class in android?
body: <p>I have Adapter class called CustomListAdapter class i written like this,so here i get a problem class cast exception Any one suggest me</p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null)
          convertView = inflater.inflate(R.layout.myplace, null);
  
      final ImageView ivCamera = (ImageView)convertView.findViewById(R.id.ivCamera);
  
      ivCamera.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              AlertDialog.Builder adb = new AlertDialog.Builder(v.getRootView().getContext());
              adb.setTitle("Do u Want to Take Photo");
              adb.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      count++;
                      String file = dir+count+".jpg";
                      File newfile = new File(file);
                      try {
                          newfile.createNewFile();
                      } catch (IOException e) {
                          e.printStackTrace();
                      }
  
                      Uri outputFileUri = Uri.fromFile(newfile);
  
                      Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                      cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
  
                      ((Activity) context).startActivityForResult(cameraIntent, TAKE_PHOTO_CODE);
  
                  }
              });
  
              adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
  
                  }
              });
  
              adb.show();
          }
      });
  }
  </code></pre>
  
  <p>I get class cast exception please suggest me how to resolve this issue</p>
  
  <p>in My Activity i call This method</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      customListAdapter.onActivityResult(requestCode, resultCode, data);
      Bitmap bp = (Bitmap) data.getExtras().get("data");
      ivCamera.setImageBitmap(bp);
  }
  </code></pre>