I wrote a class MyIntent that extends Intent. and then I use an instance of MyIntent to call the startActivity (MyIntent) function.
MyIntent i=new MyIntent(this,NewActivity.class);
constructor:
public MyIntent(Context context,Class<?> cls){
super(context,cls);
putExtra(var1,var2);
((Activity)context).startActivity(this);
}
however, when I call getIntent () in a new running action, the return value of getIntent () is Intent not MyIntent, i.e.
getIntent() instanceof Intent // true;
getIntent() instanceof MyIntent // false;
when I try (MyIntent) getIntent (), the system throws me a ClassCastException. How?
source
share