We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Java.Lang.NullPointerException when show Popup.

Thread ID:

Created:

Updated:

Platform:

Replies:

150197 Dec 25,2019 09:43 AM UTC Dec 30,2019 02:07 PM UTC Xamarin.Forms 2
loading
Tags: SfPopup
Nguyen Khoa Lu
Asked On December 25, 2019 09:51 AM UTC

Notify: Java.Lang.NullPointerException: 'Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference'

Source:
private static SfPopupLayout popupAlert;
 public static async Task DisplayAlert(string title, string message, string btnAccept)
        {
            if (popupAlert != null)
                popupAlert.IsOpen = false;
            popupAlert = new SfPopupLayout();
            if (string.IsNullOrEmpty(title))
                popupAlert.PopupView.ShowHeader = false;

            popupAlert.PopupView.PopupStyle.AcceptButtonTextColor = Color.FromHex("#3F51B5");

            popupAlert.StaysOpen = true;
            popupAlert.PopupView.ShowCloseButton = false;
            popupAlert.PopupView.AnimationMode = AnimationMode.None;
            popupAlert.PopupView.AutoSizeMode = AutoSizeMode.Height;
            popupAlert.PopupView.HeaderTitle = title;
            popupAlert.PopupView.AcceptButtonText = "    " + btnAccept + "    ";
            popupAlert.PopupView.ContentTemplate = ContentAlert(message);
            popupAlert.IsOpen = true;
            while (popupAlert.IsOpen)
            {
                await Task.Delay(100);
            }
        }

My issue:
- I call my method DisplayAlert when Load application. My Page.Content  is SfPopupLayout (X) , but when MainActivity call method LoadApplication(new App()), X has not been contructor. And X.Content has not been show. 
- And I have the error when using popupAlert.IsOpen = true; I need solution, And I think we need the Variable popupAlert.CanOpen...etc. I was tried Try Catch but it not working. 

Thanks you


Nguyen Khoa Lu
Replied On December 28, 2019 01:03 AM UTC

Who can help me? Please

Deepika Balasubramaniyan [Syncfusion]
Replied On December 30, 2019 02:07 PM UTC

Hi Nguyen Khoa Lu,

Thank you for contacting Syncfusion support.

We have checked reported issue “Java.Lang.NullPointerException when show Popup” with given settings, We are unable to replicate the issue from our side. As you instructed Popup settings added method named as “DisplayAlert has called when load application. When load the page, popup has open with out any crash as expected. For your reference we have attached the tested sample following here. If the sample doesn’t meet your requirement, kindly modify the sample based on your scenario and revert us back with replication procedure and with following details,it will be helpful for us to give you a better solution.


      1. SfPopupLayout Product version

2. Xamarin Forms version
3. Issue replicated Android device

Sample link:
https://www.syncfusion.com/downloads/support/forum/150197/ze/F1501971503577096.zip

Regards,
Deepika.




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon