ホームボタンを押すと落ちるアプリがあるのですが、
戻るボタンはダッシュボードに問題なく表示されますが、ホームを押すと次のようにクラッシュします。
07-02 16:50:51.834: E/AndroidRuntime(343): java.lang.RuntimeException: アクティビティを一時停止できません {com.rt.paging/com.rt.paging.MKpagerActivity}: java.lang.NullPointerException
これは私のコードです
public class MKpagerActivity extends FragmentActivity {
private PagerAdapter mPagerAdapter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//initialsie the pager
this.initialisePaging(); //crea un metodo! y lo implementa abajo!
}
/**
* Initialise the fragments to be paged
*/
private void initialisePaging() {
List<Fragment> fragments = new Vector<Fragment>();
fragments.add(Fragment.instantiate(this, Fragmen1.class.getName()));
fragments.add(Fragment.instantiate(this, Fragmen2.class.getName()));
this.mPagerAdapter = new com.orchard.paging.PagerAdapter(super.getSupportFragmentManager(), fragments); //por que hay q decirle el paquete??
//
ViewPager pager = (ViewPager)super.findViewById(R.id.viewpager);
pager.setAdapter(this.mPagerAdapter);
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
// your stuff or nothing
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// your stuff or nothing
}
}
これは私のlogCatです
07-02 17:15:11.545: E/AndroidRuntime(327): FATAL EXCEPTION: main
07-02 17:15:11.545: E/AndroidRuntime(327): java.lang.RuntimeException: Unable to pause activity {com.orchard.paging/com.orchard.paging.MKpagerActivity}: java.lang.NullPointerException
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2354)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2311)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2291)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.ActivityThread.access$1700(ActivityThread.java:117)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:938)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.os.Looper.loop(Looper.java:123)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-02 17:15:11.545: E/AndroidRuntime(327): at java.lang.reflect.Method.invokeNative(Native Method)
07-02 17:15:11.545: E/AndroidRuntime(327): at java.lang.reflect.Method.invoke(Method.java:507)
07-02 17:15:11.545: E/AndroidRuntime(327): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-02 17:15:11.545: E/AndroidRuntime(327): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-02 17:15:11.545: E/AndroidRuntime(327): at dalvik.system.NativeStart.main(Native Method)
07-02 17:15:11.545: E/AndroidRuntime(327): Caused by: java.lang.NullPointerException
07-02 17:15:11.545: E/AndroidRuntime(327): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:481)
07-02 17:15:11.545: E/AndroidRuntime(327): at com.orchard.paging.MKpagerActivity.onSaveInstanceState(MKpagerActivity.java:50)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.Activity.performSaveInstanceState(Activity.java:1037)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1181)
07-02 17:15:11.545: E/AndroidRuntime(327): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2336)
07-02 17:15:11.545: E/AndroidRuntime(327): ... 12 more
それで、何が足りないのですか?なぜクラッシュしたのですか?
コードの犯罪者のビットはどの行を読むのですか?
ありがとう!