在Android上从onCreate销毁活动的问题

| 如果没有可用的连接,我正在尝试停止我的应用程序
public class App extends DroidGap {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cm.getActiveNetworkInfo() == null) {
        new AlertDialog.Builder(this).setMessage(\"Para usar o Taxi Simples você precisa estar conectado!\").setCancelable(false)
                .setNeutralButton(\"fechar\", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        App.this.finish();
                    }
                }).create().show();
    } else {
        super.loadUrl(\"file:///android_asset/www/index.html\");
    }
}
出现对话框,然后单击按钮,它破坏了活动,但是此后,我收到一个android错误“应用程序意外停止”
05-23 11:04:14.596: ERROR/AndroidRuntime(768): Uncaught handler: thread main exiting due to uncaught exception
05-23 11:04:14.616: ERROR/AndroidRuntime(768): java.lang.RuntimeException: Unable to destroy activity {br.com.taxisimples/br.com.taxisimples.App}: java.lang.NullPointerException
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3469)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3487)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.app.ActivityThread.access$2800(ActivityThread.java:119)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.os.Looper.loop(Looper.java:123)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.app.ActivityThread.main(ActivityThread.java:4363)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at java.lang.reflect.Method.invokeNative(Native Method)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at java.lang.reflect.Method.invoke(Method.java:521)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at dalvik.system.NativeStart.main(Native Method)
05-23 11:04:14.616: ERROR/AndroidRuntime(768): Caused by: java.lang.NullPointerException
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at com.phonegap.DroidGap.onDestroy(DroidGap.java:657)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3456)
05-23 11:04:14.616: ERROR/AndroidRuntime(768):     ... 11 more
    
已邀请:

要回复问题请先登录注册