2014-01-27 41 views
-1

我想在我的片段級上恢復活動呼叫,但我收到以下錯誤上恢復活動調用的時候得到一個錯誤在片段通話功能的Android

@Override 
    public void onResume() { 
     super.onResume(); 
     getActivity().setContentView(R.layout.start_gps); 
     task.update(); 
    } 

這是錯誤

01-27 00:53:52.138: E/AndroidRuntime(29010): FATAL EXCEPTION: main 
01-27 00:53:52.138: E/AndroidRuntime(29010): java.lang.NullPointerException 
01-27 00:53:52.138: E/AndroidRuntime(29010): at com.lifesymb.gps.StartActivity.onResume(StartActivity.java:137) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.Fragment.performResume(Fragment.java:1521) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:963) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.os.Handler.handleCallback(Handler.java:725) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.os.Handler.dispatchMessage(Handler.java:92) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.os.Looper.loop(Looper.java:158) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.app.ActivityThread.main(ActivityThread.java:5751) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at java.lang.reflect.Method.invokeNative(Native Method) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at java.lang.reflect.Method.invoke(Method.java:511) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850) 
01-27 00:53:52.138: E/AndroidRuntime(29010): at dalvik.system.NativeStart.main(Native Method) 

回答

0

這個問題可能與task變量有關,你可能沒有重新初始化它。設置內容視圖應在onCreate中完成,您不需要在簡歷上執行