The code in the fragment context is null
public class Placeholderfragment extends Fragment{context Context = Getactivity ();}
This defines the context is null, of course, my actual code is not written like this, but this meaning, if it is in the activity is not empty, in the fragment is null.
Code context in activity is not NULL
public class Mainactivity extends Fragmentactivity {context context = this;}
The following way to get the context throws an exception
public class Mainactivity extends Fragmentactivity {Context context = getapplicationcontext ();;}
The above is just a matter of defining a single variable, and if the activity you write to the OnCreate method is certainly possible.
Met on the record, we see also will leave a heart.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android context Null pointer exception