mainに存在する下記のコードによってアクティビティを呼び出します。
Java
1 Intent obj = new Intent(this,ui_menu.class); 2 startActivity(obj);//←A地点
ui_menuは、下記のコードを書き込んでいます。
Java
1public class ui_menu extends AppCompatActivity { 2 MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.apoptosis); 3 4 @Override 5 protected void onCreate(Bundle savedInstanceState) 6 { 7 super.onCreate(savedInstanceState);//←B地点 8 setContentView(R.layout.activity_usochimei_menu); 9 10 } 11 12 protected void onStop(Bundle savedInstanceState) 13 { 14 super.onStop(); 15 16 //音楽を終了する 17 mediaPlayer.stop(); 18 } 19 20 protected void onStart(Bundle savedInstanceState) 21 { 22 super.onStart(); 23 24 //音楽を開始する 25 mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.apoptosis); 26 mediaPlayer.start(); 27 } 28}
実機デバッグでは(1ステップごとにするもの)上記コードの「A地点」は通りますが、その後、「B地点」に到達することなくフリーズします。
やりたいこと:ui_menuを開始する。
解決策をご教示ください。
【追記】
A地点からB地点の間に、Android Studioは、下記のコードを実行するようです(デバッグ中に判明)。
Java
1 final void performRestart() { 2 mFragments.noteStateNotSaved(); 3 4 if (mToken != null && mParent == null) { 5 // No need to check mStopped, the roots will check if they were actually stopped. 6 WindowManagerGlobal.getInstance().setStoppedState(mToken, false /* stopped */); 7 } 8 9 if (mStopped) { 10 mStopped = false; 11 12 synchronized (mManagedCursors) { 13 final int N = mManagedCursors.size(); 14 for (int i=0; i<N; i++) { 15 ManagedCursor mc = mManagedCursors.get(i); 16 if (mc.mReleased || mc.mUpdated) { 17 if (!mc.mCursor.requery()) { 18 if (getApplicationInfo().targetSdkVersion 19 >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { 20 throw new IllegalStateException( 21 "trying to requery an already closed cursor " 22 + mc.mCursor);//←A-1 23 } 24 } 25 mc.mReleased = false; 26 mc.mUpdated = false; 27 } 28 } 29 } 30 31 mCalled = false; 32 mInstrumentation.callActivityOnRestart(this); 33 if (!mCalled) { 34 throw new SuperNotCalledException( 35 "Activity " + mComponent.toShortString() + 36 " did not call through to super.onRestart()"); 37 } 38 performStart(); 39 } 40 }
このコードの「throw new IllegalStateException("trying to requery an already closed cursor "+ mc.mCursor);」が実行され(上記「A-1」)、その後フリーズします。
これがフリーズと関係あるのでしょうか?(throwではあるが、エラーではない・・・?いかし、IllegalStateExceptionを検索すると、「不正または不適切~」とヒット)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。