When calling the startActivityForResult() method from its own adapter, an error is displayed
E/AndroidRuntime: FATAL EXCEPTION: main Process: ilhom4ik_app.com.girbar, PID: 9561 java.lang.ClassCastException: android.app.Application cannot be cast to android.app.Activity at ilhom4ik_app.com.girbar.ItemsAdapter$1.onClick(ItemsAdapter.java:65) at android.view.View.performClick(View.java:5637) at android.view.View$PerformClick.run(View.java:22429) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Calling activation from the adapter like this
holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent item = new Intent(mContext,ItemActivity_level1.class); item.putExtra("item",itemList.getUrl()); item.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Activity activity = (Activity) mContext; activity.startActivityForResult(item,1); } });