FragmentStackSupport
Activity のコンテキストを取得して、内部の静的クラスで使用しようとしています。
FragmentStackSupport
内部静的クラスでインスタンス化し、getBaseContext()
のコンテキストを取得するために使用していますFragmentStackSupport
。
外側のクラス コンテキストを内部に配置GCMRegistar.checkDevice(thisContext)
しても、コードでエラーは発生しませんが、アプリケーションがクラッシュします。
「this」を使用できないかFragmentStackSupport.this
、内部クラスが static であるためです。「これ」は、クラスが公開されている場合に機能します...
メソッドのコンテキストを正しく取得するにはどうすればよいcheckDevice()
ですか?
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);
}
}
}