خرید بک لینک

Vote count: 0

Following google sign in guide I have implemented it in my app and it works as expected however on the first trials I got a null exception when trying to get the profile. So after some search i found GoogleSignInAccount getPhotoUrl() retu null and it really appears that there is like a sync issue after removing and adding google account i was managed to properly get the photo url.

Currently the data I am trying to get is in try catch block as below:

            try{
            GoogleSignInAccount acct = result.getSignInAccount();

            //Log.d(TAG,acct.getDisplayName());
            String UserName = acct.getDisplayName();
            String UserEmail=acct.getEmail();
            String UserID=acct.getId();
            String UserPhoto = acct.getPhotoUrl().toString();;

            Log.d(TAG,UserPhoto);
            Log.d(TAG,UserName);
            Log.d(TAG,UserEmail);
            Log.d(TAG,UserID);
        }catch (Exception e){
            e.printStackTrace();

        }

My question is how can i handle a case where part of the information is missing? how can i distinguish between acct.getPhotoUrl().toString(); that can produce NPE and acct.getDisplayName(); that can produce NPE as well?

Anyone has an Idea?.

asked 2 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 25 بهمن 1394 ساعت: 18:21

صفحه بندی