I am building a game using google play game services on RealTimeMultiplayer concept, my questions is how to get access the all participants profile image to display. i am new to the google play game services, not found a solutions or any guidance on API. please guide me, can we access and how to access?
            Asked
            
        
        
            Active
            
        
            Viewed 999 times
        
    1 Answers
3
            
            
        Using the ImageManager class to load the ImagerUri is how I tackle it.
Below, I loop through each Participant in the currentRoom, and request their IconImageUri to be loaded by an ImageManager instance.
This can directly be used to inflate a view, but as I am using LibGDX, I save it as png for it to handle.
(You can see that I tell theGameInterface that it is null if their is no pic, either because there isn't one, or they are an "unknown" participant and therefore GPGS returns null)
        for (Participant p : mRoomCurrent.getParticipants()) {
            //makeToast("should be loading pic");
            ImageManager IM = ImageManager.create(this);
            IM.loadImage(new ImageManager.OnImageLoadedListener() {             
                @Override
                public void onImageLoaded(Uri arg0, Drawable drawable, boolean arg2) {
                    if(drawable == null) {
                        theGameInterface.picLoaded(participantID, null);
                    } else {
                        Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
                        try {
                           FileOutputStream out = openFileOutput("pic" + participantID + ".png", Context.MODE_MULTI_PROCESS);
                           bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
                           out.flush();
                           out.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                            //dLog(e.getStackTrace().toString());
                        }
                    }
            }
            }, p.getIconImageUri());
These were deduced from developer site
        user2346305
        
- 1,912
 - 14
 - 21