Reputation: 782
I'm letting my app user's sign in to their Google+ account. When they do, I want to display their profile picture in the corner of every activity to show they are logged in. What are some good (and not so good) ways to do this? I thought about converting the bitmap to base62 and storing as a string but I've seen people say that method is not recommended. Any ideas? Thanks!
Upvotes: 2
Views: 136
Reputation: 57336
I would store the file in internal storage and use it from there as many times as you need:
Bitmap bmp = ...; // get your bitmap from Google
String filename = "image.png"
FileOutputStream outputStream;
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
bmp.compress(CompressFormat.PNG, 75, outputStream);
outputStream.close();
Then later you can load your bitmap from the file:
InputStream is = activity.openFileInput("image.png");
Bitmap b = BitmapFactory.decodeStream(is);
This way the bitmap will even be saved between invocations of your app.
Upvotes: 1
Reputation: 617
This quite simple you can convert bitmap into base 64 key and use this in each activity or you can use Action bar which will be similar for all activity
Upvotes: 3
Reputation: 61
I would highly recommend using a LruCache
which works by allocating a specified amount of memory on the device's ram and removes old images to keep room, or clears it when the device needs more room for memory.
Upvotes: 0