使用以下代码
从片段DialogFragment链接到网页时崩溃 DialogInterface.OnClickListener MoreInfoListener = new DialogInterface.OnClickListener() {
private String url = "http://penny.hpp.io/?p=63";
public void onClick(DialogInterface dialog, int id) {
if (checkConnectivity()){
final Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url));
getActivity().startActivity(intent);
}
}
与崩溃相关的错误如下:
12-03 14:26:09.660: E/AndroidRuntime(17567): FATAL EXCEPTION: main
12-03 14:26:09.660: E/AndroidRuntime(17567): java.lang.RuntimeException: Unable to stop activity {com.harmonicprocesses.penelopefree/com.harmonicprocesses.penelopefree.PenelopeMainActivity}: java.lang.NullPointerException
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3028)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3074)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.ActivityThread.access$1000(ActivityThread.java:143)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1268)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.os.Looper.loop(Looper.java:137)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.ActivityThread.main(ActivityThread.java:4950)
12-03 14:26:09.660: E/AndroidRuntime(17567): at java.lang.reflect.Method.invokeNative(Native Method)
12-03 14:26:09.660: E/AndroidRuntime(17567): at java.lang.reflect.Method.invoke(Method.java:511)
12-03 14:26:09.660: E/AndroidRuntime(17567): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
12-03 14:26:09.660: E/AndroidRuntime(17567): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
12-03 14:26:09.660: E/AndroidRuntime(17567): at dalvik.system.NativeStart.main(Native Method)
12-03 14:26:09.660: E/AndroidRuntime(17567): Caused by: java.lang.NullPointerException
12-03 14:26:09.660: E/AndroidRuntime(17567): at com.harmonicprocesses.penelopefree.camera.Pcamera.stop(Pcamera.java:137)
12-03 14:26:09.660: E/AndroidRuntime(17567): at com.harmonicprocesses.penelopefree.PenelopeMainActivity.onStop(PenelopeMainActivity.java:522)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1219)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.Activity.performStop(Activity.java:5317)
12-03 14:26:09.660: E/AndroidRuntime(17567): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3025)
12-03 14:26:09.660: E/AndroidRuntime(17567): ... 11 more
我无法想出这个。请帮忙。它会打开链接,但应用程序会在后台崩溃。因此,当按下后退按钮时,它不会像往常一样返回应用程序。