Created
July 6, 2015 12:51
-
-
Save wszdwp/9843fba7b907c81ee480 to your computer and use it in GitHub Desktop.
Base64 in Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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