Skip to content

Instantly share code, notes, and snippets.

@wszdwp
Created July 6, 2015 12:51
Show Gist options
  • Select an option

  • Save wszdwp/9843fba7b907c81ee480 to your computer and use it in GitHub Desktop.

Select an option

Save wszdwp/9843fba7b907c81ee480 to your computer and use it in GitHub Desktop.
Base64 in Android
//test decoding
mImageView.setImageDrawable(getResources().getDrawable(R.drawable.no_image));
String s = PictureDb.getPictureBase64Str(picName);
Log.v(LOG_TAG, "get the base64 String and start to decode");
byte[] decodedByte = Base64.decode(s, 0);
Bitmap nBitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
mImageView.setImageBitmap(nBitmap);
Log.v(LOG_TAG, PictureDb.getPictureName(picName));
Type listType = new TypeToken<List<String>>() {}.getType();
List<String> target = new LinkedList<String>();
target.add("blah");
Gson gson = new Gson();
String json = gson.toJson(target, listType);
List<String> target2 = gson.fromJson(json, listType);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment