Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Getting Error When Push Notification Clicked

Richy_GeorgeRichy_George INMember ✭✭✭

Error Message: Java.Lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{8292aa7 V.E..... R.....ID 0,0-684,232} not attached to window manager.

Build:
03-09 20:32:05.522 E/mono (16027):
03-09 20:32:05.522 E/mono (16027): Unhandled Exception:
03-09 20:32:05.522 E/mono (16027): Java.Lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{344bcaed V.E..... R.....ID 0,0-456,174} not attached to window manager
03-09 20:32:05.522 E/mono (16027): --- End of managed Java.Lang.IllegalArgumentException stack trace ---
03-09 20:32:05.522 E/mono (16027): java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{344bcaed V.E..... R.....ID 0,0-456,174} not attached to window manager
03-09 20:32:05.522 E/mono (16027): at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:389)
03-09 20:32:05.522 E/mono (16027): at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:315)
03-09 20:32:05.522 E/mono (16027): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
03-09 20:32:05.522 E/mono (16027): at android.app.Dialog.dismissDialog(Dialog.java:341)
03-09 20:32:05.522 E/mono (16027): at android.app.Dialog.dismiss(Dialog.java:324)
03-09 20:32:05.522 E/mono (16027): at mono.java.lang.RunnableImplementor.n_run(Native Method)
03-09 20:32:05.522 E/mono (16027): at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
03-09 20:32:05.522 E/mono (16027): at android.os.Handler.handleCallback(Handler.java:810)
03-09 20:32:05.522 E/mono (16027): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 20:32:05.522 E/mono (16027): at android.os.Looper.loop(Looper.java:189)
03-09 20:32:05.522 E/mono (16027): at android.app.ActivityThread.main(ActivityThread.java:5529)
03-09 20:32:05.522 E/mono (16027): at java.lang.reflect.Method.invoke(Native Method)
03-09 20:32:05.522 E/mono (16027): at java.lang.reflect.Method.invoke(Method.java:372)
03-09 20:32:05.522 E/mono (16027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
03-09 20:32:05.522 E/mono (16027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
03-09 20:32:05.522 E/mono (16027):
03-09 20:32:05.522 E/mono-rt (16027): [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{344bcaed V.E..... R.....ID 0,0-456,174} not attached to window manager
03-09 20:32:05.522 E/mono-rt (16027): --- End of managed Java.Lang.IllegalArgumentException stack trace ---
03-09 20:32:05.522 E/mono-rt (16027): java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{344bcaed V.E..... R.....ID 0,0-456,174} not attached to window manager
03-09 20:32:05.522 E/mono-rt (16027): at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:389)
03-09 20:32:05.522 E/mono-rt (16027): at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:315)
03-09 20:32:05.522 E/mono-rt (16027): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
03-09 20:32:05.522 E/mono-rt (16027): at android.app.Dialog.dismissDialog(Dialog.java:341)
03-09 20:32:05.522 E/mono-rt (16027): at android.app.Dialog.dismiss(Dialog.java:324)
03-09 20:32:05.522 E/mono-rt (16027): at mono.java.lang.RunnableImplementor.n_run(Native Method)
03-09 20:32:05.522 E/mono-rt (16027): at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
03-09 20:32:05.522 E/mono-rt (16027): at android.os.Handler.handleCallback(Handler.java:810)
03-09 20:32:05.522 E/mono-rt (16027): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 20:32:05.522 E/mono-rt (16027): at android.os.Looper.loop(Looper.java:189)
03-09 20:32:05.522 E/mono-rt (16027): at android.app.ActivityThread.main(ActivityThread.java:5529)
03-09 20:32:05.522 E/mono-rt (16027): at java.lang.reflect.Method.invoke(Native Method)
03-09 20:32:05.522 E/mono-rt (16027): at java.lang.reflect.Method.invoke(Method.java:372)
03-09 20:32:05.522 E/mono-rt (16027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
03-09 20:32:05.522 E/mono-rt (16027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
03-09 20:32:05.522 E/mono-rt (16027):
03-09 20:32:05.522 E/ion (16027): ion close failed!, fd=-1202969016, -1: Bad file number.
03-09 20:32:05.522 E/[MALI]Gralloc-ERROR: int alloc_device_close(hw_device_t*):836 Failed to close ion_client: -1202969016

Answers

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @Richy_George - its hard to see what is happening without your code, however it looks like you are trying to display a dialog or start an activity when you press the push notification and it is most likely around that code where the issue is.

  • Richy_GeorgeRichy_George INMember ✭✭✭

    @AdamP Sorry for the late response

    in Android MainActivity

            if (IsPlayServicesAvailable())
            {
                // Start the registration intent service; try to get a token:
                var intent = new Intent(this, typeof(RegistrationIntentService));
                StartService(intent);
                string parameterValue = this.Intent.GetStringExtra("param");
                //string parameterValue = string.IsNullOrEmpty(intent.Extras.GetString("param")) ? string.Empty : intent.Extras.GetString("param");
                if (parameterValue != null)
                {
                    NotificationManager notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
                    notificationManager.Cancel(1);
                    LoadApplication(new App(parameterValue));
                }
                else
                {
                    parameterValue = string.Empty;
                    NotificationManager notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
                    notificationManager.Cancel(1);
                    LoadApplication(new App(parameterValue));
                }
            }
    

    In App.cs(PCL)

        public App(string PushNotifParameter)
        {
            param = PushNotifParameter;
            // The root page of your application
            var profilePage = new LoginPage();
            _NavPage = new NavigationPage(profilePage);
            Current.Resources = new ResourceDictionary();
            Current.Resources.Add("UlycesColor", Color.FromRgb(121, 248, 81));
            var navigationStyle = new Style(typeof(NavigationPage));
            var barTextColorSetter = new Setter { Property = NavigationPage.BarTextColorProperty, Value = Color.FromHex("#f2f2f2") };
            var barBackgroundColorSetter = new Setter { Property = NavigationPage.BarBackgroundColorProperty, Value = Color.FromHex("#940369") };
            navigationStyle.Setters.Add(barTextColorSetter);
            navigationStyle.Setters.Add(barBackgroundColorSetter);
            Current.Resources.Add(navigationStyle);
            // This lookup NOT required for Windows platforms - the Culture will be automatically set
            if (Device.OS == TargetPlatform.iOS || Device.OS == TargetPlatform.Android)
            {
                // determine the correct, supported .NET culture
                var ci = DependencyService.Get<ILocalize>().GetCurrentCultureInfo();
                Resx.AppResources.Culture = ci; // set the RESX for resource localization
                DependencyService.Get<ILocalize>().SetLocale(ci); // set the Thread for locale-aware methods
            }
            int val = Helpers.Settings.UsersSession;
            if (val == 0)
            {
                MainPage = new LoginPage();
            }
            else
            {
                if (param == string.Empty || param == null)
                {
                    //// Clear all notification
                    //var localpush = DependencyService.Get<INotificationHub>();
                    //localpush.clearallnotif();
                    // The root page of your application
                    MainPage = new MainPage();
                }
                else
                {
                    //// Clear all notification
                    //var localpush = DependencyService.Get<INotificationHub>();
                    //localpush.clearallnotif();
                    NavigationPage np = new NavigationPage(new NotificationPage());
                    MainPage = np;
                    // For Android and WinPhone, Process the Push Notification click....
                }
            }
        }
    
Sign In or Register to comment.