Hi I am developing small android application. So my application contains following things. 3 Activities consider A1, A2, A3. A1 is my launcher activity. my application also contains one background service. So when I click on button inside A1 it will start background service.
Inside background service I am starting A2. I am also doing some calculations in service so after those calculations i am starting activity A3 from service only. SO my problem is here when I start service from A1 it will open A2 from service. If I click back from there(A2 to A1) it will come back to A1. But in case of (A1 -> service -> A2 -> A3(this also started from service)) if i click on back it will causes unable to pause activity exception error. It will not resume A1.
When I start activity from service I am using Intent.FLAG_ACTIVITY_NEW_TASK
. Where is the problem? need Help Thank you
See this is my error log:
01-17 14:45:03.689: E/AndroidRuntime(27805): FATAL EXCEPTION: main
01-17 14:45:03.689: E/AndroidRuntime(27805): java.lang.RuntimeException: Unable to pause activity { ABC/ ABC.map.MapActivity}: java.lang.IllegalStateException
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2709)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2665)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2643)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.ActivityThread.access$800(ActivityThread.java:124)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.os.Handler.dispatchMessage(Handler.java:99)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.os.Looper.loop(Looper.java:137)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.ActivityThread.main(ActivityThread.java:4436)
01-17 14:45:03.689: E/AndroidRuntime(27805): at java.lang.reflect.Method.invokeNative(Native Method)
01-17 14:45:03.689: E/AndroidRuntime(27805): at java.lang.reflect.Method.invoke(Method.java:511)
01-17 14:45:03.689: E/AndroidRuntime(27805): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-17 14:45:03.689: E/AndroidRuntime(27805): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-17 14:45:03.689: E/AndroidRuntime(27805): at dalvik.system.NativeStart.main(Native Method)
01-17 14:45:03.689: E/AndroidRuntime(27805): Caused by: java.lang.IllegalStateException
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.media.MediaPlayer._stop(Native Method)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.media.MediaPlayer.stop(MediaPlayer.java:977)
01-17 14:45:03.689: E/AndroidRuntime(27805): at ABC.map.MapActivity.onPause(MapActivity.java:170)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.Activity.performPause(Activity.java:4564)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1195)
01-17 14:45:03.689: E/AndroidRuntime(27805): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2696)
01-17 14:45:03.689: E/AndroidRuntime(27805): ... 12 more