Android in the non-Activity, the intent page jump problem

Copyright statement: This article is the original article of the blogger and follows the CC 4.0 BY-SA copyright agreement. Please attach the link to the original source and this statement for reprinting.
Link to this article: https://blog.csdn.net/u013339223/article/details/37597419
Under Activity, we know that the page jumps as follows:

Intent intent = new Intent();
intent.setClass(Current Activity.this, Jump to Activity.class);
startActivity(intent);
In non-Activity, such as custom adapter. We need to define a running context to start the page Jump:

private Context context; //Run context
Intent intent = new Intent();
intent.setClass(context, Jump to Activity.class);
context.startActivity(intent);

Guess you like

Origin blog.csdn.net/qq_41915623/article/details/100798119