when a call comes, your activity goes to background and the phone app's activity becomes active. You're trying to show a dialog that is tied to a activity that's not running at the moment, thus the error. "Toast"s don't have these strong ties to the activity showing them. that's why it works.
2011/11/2 Sunil Mishra <suniljmis...@gmail.com> > Hi, > > The log - > > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): FATAL EXCEPTION: main > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): > android.view.WindowManager$BadTokenException: Unable to add window -- > token android.os.BinderProxy@44e7d968 is not valid; is your activity > running? > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.view.ViewRoot.setView(ViewRoot.java:505) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.view.Window$LocalWindowManager.addView(Window.java:424) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.app.Dialog.show(Dialog.java:241) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > com.motorola.EzeeTransferActivity > $1.onCallStateChanged(EzeeTransferActivity.java:63) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.telephony.PhoneStateListener > $2.handleMessage(PhoneStateListener.java:319) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.os.Handler.dispatchMessage(Handler.java:99) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.os.Looper.loop(Looper.java:123) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > android.app.ActivityThread.main(ActivityThread.java:4627) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > java.lang.reflect.Method.invokeNative(Native Method) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > java.lang.reflect.Method.invoke(Method.java:521) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > com.android.internal.os.ZygoteInit > $MethodAndArgsCaller.run(ZygoteInit.java:868) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > 11-02 11:25:57.706: ERROR/AndroidRuntime(339): at > dalvik.system.NativeStart.main(Native Method) > > > On Oct 26, 7:36 am, gjs <garyjamessi...@gmail.com> wrote: > > Hi, > > > > Examine or post console log showing the error. > > > > Regards > > > > On Oct 25, 8:10 pm,SunilMishra<suniljmis...@gmail.com> wrote: > > > > > > > > > > > > > > > > > Hi, > > > > > I have written a code to display a dialog box when a incoming call > > > arrives, but it crashes. > > > It is working fine when done by only displaying message using Toast. > > > > > Please Help. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 株式会社アルゴ ARGO Inc. 〒130-0012 東京都墨田区太平3-11-10 NTKオオノビル8階 ソアレス フランシスコ ( Soares Francisco ) Mail : soa...@argo.bz HP : http://www.argo.bz/ TEL:03-5619-4511 FAX:03-5619-4512 -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en