在使用共享意向的应用程序崩溃并出现以下错误
01-25 12:16:09.270: E/AndroidRuntime(28699): FATAL EXCEPTION: main
01-25 12:16:09.270: E/AndroidRuntime(28699): java.lang.NullPointerException
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:481)
01-25 12:16:09.270: E/AndroidRuntime(28699): at com.actionbarsherlock.app.SherlockFragmentActivity.onSaveInstanceState(SherlockFragmentActivity.java:127)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.app.Activity.performSaveInstanceState(Activity.java:1113)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1188)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2805)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:2863)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.app.ActivityThread.access$900(ActivityThread.java:127)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1173)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.os.Handler.dispatchMessage(Handler.java:99)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.os.Looper.loop(Looper.java:137)
01-25 12:16:09.270: E/AndroidRuntime(28699): at android.app.ActivityThread.main(ActivityThread.java:4507)
01-25 12:16:09.270: E/AndroidRuntime(28699): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 12:16:09.270: E/AndroidRuntime(28699): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 12:16:09.270: E/AndroidRuntime(28699): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-25 12:16:09.270: E/AndroidRuntime(28699): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-25 12:16:09.270: E/AndroidRuntime(28699): at dalvik.system.NativeStart.main(Native Method)
PlacesActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_share:
// Google Analytics Tracking
GATracker.sendEvent("ui_action", "button_press", "share",
click_value);
shareIt();
break;
default:
break;
}
return true;
}
private void shareIt() {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareText = name + "\n" + distance + " kms - " + days + " days"
+ "\n" + todo + "\n\n"
+ "Check out Nomad for Android http://goo.gl/i1mH9";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Check out this!!");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareText);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
}