Java Android - How I decode BASE64URL body data message to UTF-8 -


i have json ouptup gmail api: message body parts (get message gmail api)

text/plain

sgvsbg8gahr0cdovl3n0ywnrb3zlcmzsb3cuy29tlybhbmqgdghhbmsgew91igzvcib5b3vyighlbhahlg0k 

text/html

pgrpdibkaxi9imx0cii-pgrpdibjbgfzcz0iz21hawxfzgvmyxvsdcigc3r5bgu9imzvbnqtzmftawx5onzlcmrhbmesc2fucy1zzxjpzii-sgvsbg_codxhighyzwy9imh0dha6ly9zdgfja292zxjmbg93lmnvbs8ipmh0dha6ly9zdgfja292zxjmbg93lmnvbs88l2e-igfuzcb0agfuayb5b3ugzm9yihlvdxigagvscceupc9kaxy-pgrpdibjbgfzcz0iz21hawxfzgvmyxvsdcigc3r5bgu9imzvbnqtzmftawx5onzlcmrhbmesc2fucy1zzxjpzii-pgjypjwvzgl2pjxkaxy-pgjypjwvzgl2pjxkaxygy2xhc3m9imdtywlsx3npz25hdhvyzsigzgf0ys1zbwfydg1haww9imdtywlsx3npz25hdhvyzsi-pgrpdibkaxi9imx0cii-pgrpdj48zgl2igrpcj0ibhryij48zgl2pjxkaxygzglypsjsdhiipjxkaxy-pgrpdibkaxi9imx0cii-pc9kaxy-pc9kaxy-pc9kaxy-pc9kaxy-pc9kaxy-pc9kaxy-pc9kaxy-pc9kaxy-dqo8l2rpdj4ncg== 

i can't decode message, text/plain or text/html. tried many ways, didn't work.

//result can text/plain or text/html string above import android.util.base64; string orig = result.replaceall("-","+").replaceall("_","/"); byte[] = base64.decode(orig, base64.default); // byte[] result have content string emailresult = new string(a,"utf-8"); log.i("email ", emailresult); //blank result //or - tried  import com.google.api.client.util.base64; string c = new string(base64.decodebase64(result)); log.i("email ", a); // blank 

result length must multiple of 4? have delete characters , replace ==s ?

import android.util.base64;  int flags = base64.no_wrap | base64.url_safe; byte[] data = base64.decode(result, flags); string emailresult = new string(data, "utf-8");  log.i("email ", emailresult);  // => email <div dir="ltr"> <div class="gmail_default" ... 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -