private static final int CHANGE = 200;
// Fragment statement in context
Private the Context context; @Override public void onAttach (the Context context) { Super .onAttach (context); the this .context = context;
// This code fragment is necessary }
public void onAttach this snippet is missing, then if there will be such a mistake, the mistake before looking for a long time (white) haha
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
The first jump
In the development process, startActivityForResult is the most common scenario is its use: for example, to jump from AActivity BActivity, then do a series of operations in BActivity, and then close when you need to pass some data to return AActivity in BActivity, when BActivity or closed, or the need to interface data AActivity some changes, this time you need to use startActivityForResult.
startActivityForResult(new Intent(context,QiyeActivty.class),CHANGE);
The second jump
startActivity(new Intent(context, MyOrder.class));
Not much difference, not elaborate, because in fact, I mainly want to say is that on top of a mistake.