以下)は、Androidのコードスニペット特定のアンドロイドコードスニペットでアクティビティを一時停止できない問題を解決するにはどうすればよいですか?
runOnUiThread(new Runnable() {
public void run() {
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Network error");
alertDialog.setMessage("Disconnected");
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "ok", new DialogInterface.OnClickListener() {
/** ON clicking oKay button **/
public void onClick(DialogInterface dialog, int id)
{
hasConnectServiceStarted = false;
IP = null;
// Intent intent = getIntent();
Intent intentSplash = new Intent(getApplication().getApplicationContext(), SplashActivity.class);
/** Shutdown the nodemain executor service if
* HOST goes down
*/
nodeMainExecutorService.forceShutdown();
/** and restart the Main Activity that will prompt
* user to reconnect to the HOST once again
*/
// I want current activity to destroy before starting Splash Activity, hence calling onDestroy()
onDestroy();
startActivity(intentSplash);
}
});
alertDialog.show();
}です。
すべてが細かいようだが、この警告ダイアログが来るし、[OK]をクリックしたときに、私はエラーを以下の取得:
java.lang.RuntimeException: Unable to pause activity {edu.arizona.ece573.catgraph/edu.arizona.ece573.catgraph.MainActivity}: java.lang.IllegalStateException: No host at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3293) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3252) at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3227) at android.app.ActivityThread.access$1100(ActivityThread.java:154) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5292) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) Caused by: java.lang.IllegalStateException: No host at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1235) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1230) at android.support.v4.app.FragmentManagerImpl.dispatchPause(FragmentManager.java:2056) at android.support.v4.app.FragmentController.dispatchPause(FragmentController.java:198) at android.support.v4.app.FragmentActivity.onPause(FragmentActivity.java:401) at android.app.Activity.performPause(Activity.java:6101) at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1310) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3279) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3252) at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3227) at android.app.ActivityThread.access$1100(ActivityThread.java:154) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5292) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
どのように私はこのエラーを解決する必要がありますか?
'onDestroy();'を削除します。お願いします。 – Blackbelt
スプラッシュアクティビティ – cybodroid
を起動する前に、現在のアクティビティを破壊してアンドロイドにする必要があります。 'onDestroy() 'の代わりに' finish() 'を呼び出す – Blackbelt