I’m trying to get the context of FragmentStackSupport Activity and use it in an inner static class.
I’ve instantiated FragmentStackSupport in the inner static class and I’m using getBaseContext() to get the context of FragmentStackSupport.
Putting the outer class context inside GCMRegistar.checkDevice(thisContext) does not give an error in the code but crashes the application.
I can’t use ‘this’ or FragmentStackSupport.this because the inner class is static. “this” would work if the class was public ect…
How do I get the context correct for for checkDevice() method?
public class FragmentStackSupport extends SherlockFragmentActivity {
int mStackLevel = 1;
//...
public static class CountingFragment extends SherlockFragment implements OnClickListener{
//...
FragmentStackSupport FSSContext;
static CountingFragment newInstance(int num) {
CountingFragment f = new CountingFragment();
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
FSSContext= new FragmentStackSupport();
FSSContext.getBaseContext();
Context thisContext;
//
// Make sure the device has the proper dependencies.
GCMRegistrar.checkDevice(thisContext);
}
}
}
I found the answer, However I not sure why it works. But because I’m using sherlock action bar had to use that libaries’s specific method