title: Calling from android app and permission check
body: <p>I have an adapter which has an image button. And <code>OnClick</code> on <code>ImageButton</code> i want to call on the contact number i am parsing. Here its asking me to add permission check. I am getting class cast exception in this stage. Please help.</p>
  
  <p>This is my code:</p>
  
  <pre><code>  holder.call.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  if (ActivityCompat.checkSelfPermission(context, permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
                      // TODO: Consider calling
                      //    ActivityCompat#requestPermissions
                      // here to request the missing permissions, and then overriding
                      //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                      //                                          int[] grantResults)
                      // to handle the case where the user grants the permission. See the documentation
                      // for ActivityCompat#requestPermissions for more details.
             ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.CALL_PHONE}, MY_PERMISSIONS_REQUEST_CALL_PHONE);
                } else {
                      Intent callIntent = new Intent(Intent.ACTION_CALL);
                      callIntent.setData(Uri.parse("tel:"+storePro.getStoreContact()));
                      callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                      context.startActivity(callIntent);
                  }
  
              }
          });
  </code></pre>
  
  <p>And the exception i am getting:</p>
  
  <pre><code>FATAL EXCEPTION: main 
  java.lang.ClassCastException: com.example.project.app.AppController cannot be cast to android.app.Activity
  </code></pre>