I'm getting this error only the first time i run my app. Why? Any clue? 
Here is my code:

I'm getting user's facebook name and pic in method init() I start a service 
when a toogle botton is enabled

> public void onCreate(Bundle savedInstanceState) {
>     Log.i(TAG, "[ACTIVITY] onCreate");
>     super.onCreate(savedInstanceState);
>     setContentView(R.layout.main);
>     mUserPic = (ImageView) findViewById(R.id.user_pic);
>     mText = (TextView) findViewById(R.id.welcome_text);
>     mStepValueView = (TextView) findViewById(R.id.step_value);
>
>     // restore facebook session if exist
>     SessionStore.restore(facebook, this);
>
>     // Init facebook session
>     init();
>
>     // inizialize pedometer
>     mStepValue = 0;
>     mPaceValue = 0;
>
>     // set map
>     mapView = (MapView) findViewById(R.id.mapview);
>     mapView.setBuiltInZoomControls(true);
>     mapView.setEnabled(true);
>     mapController = mapView.getController(); // get MapController
>     mapController.setZoom(MAP_ZOOM); // zoom in the map
>
>     // register listener for toggleButton
>     ToggleButton toggleButton = (ToggleButton) findViewById(R.id.
> ToggleButton);
>     toggleButton.setOnCheckedChangeListener(toggleButtonListener);
>
> }
>
> public void onResume() {
>     Log.i(TAG, "[ACTIVITY] onResume");
>     super.onResume();
>     if (!facebook.isSessionValid()) {
>         mText.setText("User offline");
>         mUserPic.setImageBitmap(null);
>     } else {
>         facebook.extendAccessTokenIfNeeded(this, null);
>     }
>
>     // resume pedometer
>     mSettings = PreferenceManager.getDefaultSharedPreferences(this);
>     mPedometerSettings = new PedometerSettings(mSettings);
>
>     // Read from preferences if the service was running on the last 
> onPause
>     mIsRunning = mPedometerSettings.isServiceRunning();
>
>     if (mIsRunning) {
>         bindStepService();
>     }
>
>     mPedometerSettings.clearServiceRunning();
>
> }
>
> @Override
> protected void onPause() {
>     Log.i(TAG, "[ACTIVITY] onPause");
>     // if (mIsRunning) {
>     // unbindStepService();
>     // }
>     if (mQuitting) {
>         mPedometerSettings.saveServiceRunningWithNullTimestamp(mIsRunning
> );
>     } else {
>         mPedometerSettings.saveServiceRunningWithTimestamp(mIsRunning);
>     }
>
>     super.onPause();
> }
>

Logcat

> 06-27 11:48:54.101: E/AndroidRuntime(20313): FATAL EXCEPTION: main
> 06-27 11:48:54.101: E/AndroidRuntime(20313): java.lang.RuntimeException: 
> Unable to resume activity 
> {it.univpm.dii.socialfoot/it.univpm.dii.socialfoot.SocialFootActivity}: 
> java.lang.NullPointerException
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.app.ActivityThread.performResumeActivity(ActivityThread.java:2455)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2483)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1176)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.os.Handler.dispatchMessage(Handler.java:99)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.os.Looper.loop(Looper.java:137)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.app.ActivityThread.main(ActivityThread.java:4437)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> java.lang.reflect.Method.invokeNative(Native Method)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> java.lang.reflect.Method.invoke(Method.java:511)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> dalvik.system.NativeStart.main(Native Method)
> 06-27 11:48:54.101: E/AndroidRuntime(20313): Caused by: 
> java.lang.NullPointerException
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> com.google.android.maps.MapActivity.onResume(MapActivity.java:451)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> it.univpm.dii.socialfoot.SocialFootActivity.onResume(SocialFootActivity.java:296)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.app.Activity.performResume(Activity.java:4545)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    at 
> android.app.ActivityThread.performResumeActivity(ActivityThread.java:2445)
> 06-27 11:48:54.101: E/AndroidRuntime(20313):    ... 10 more
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to