I use SDKBoxPlay, success sigin, use sdkbox.PluginSdkboxPlay.getPlayerAccountField(“icon_image_uri”) to get profile image, it return uri like this: content://com.google.android.gms.games.background/images/5a905997/1, and I dont know how to show it to my game. I found some document but It require URL not URI. Thanks.
We can ask @yinjimmy to take a look.
My Cocos Creator version is 2.4.3. Thanks.
try to save the uri to file, and load image from absolute path in cocos creator.
To get Bitmap from imageView
:
imageview.buildDrawingCache();
Bitmap bm=imageview.getDrawingCache();
To save it in a file:
OutputStream fOut = null;
Uri outputFileUri;
try {
File root = new File(Environment.getExternalStorageDirectory()
+ File.separator + "folder_name" + File.separator);
root.mkdirs();
File sdImageMainDirectory = new File(root, "myPicName.jpg");
outputFileUri = Uri.fromFile(sdImageMainDirectory);
fOut = new FileOutputStream(sdImageMainDirectory);
} catch (Exception e) {
Toast.makeText(this, "Error occured. Please try again later.",
Toast.LENGTH_SHORT).show();
}
try {
bm.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
} catch (Exception e) {
}
2 Likes