Je travaille avec le lien profond et j'ai eu un problème lors du passage de la chaîne japonaise de Web à Android via IntentFilter. Il y a un code:Intention chaîne de codage automatique android
Initialiser WebView avec le code Html:
String encode = URLEncoder.encode("namhv://category?category_name=レビュー", "UTF-8");
Log.e(TAG, "Url Encode: " + encode);
Log.e(TAG, "Url Decode:" + URLDecoder.decode(encode, "UTF-8"));
WebView webView = (WebView) findViewById(R.id.wv_content);
webView.getSettings().setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
String html = "<html><body>\n" +
"<br><a href=\"" + encode + "\">test go tab</a><br>" +
"</body></html>";
Log.e(TAG, html);
webView.loadData(html, "text/html", "UTF-8");
Poignée Intention:
public boolean handleDeepLinkEvent(Intent intent) throws UnsupportedEncodingException {
if (intent.getData() != null) { //deep link
String cateName = intent.getDataString();
Log.e(TAG, cateName);
Log.e(TAG, URLDecoder.decode(cateName, "UTF-8"));
return true;
}
return false;
}
(1) chaîne d'origine: namhv: // catégorie nom_catégorie = レ ビ ュ ー
(2) Chaîne après codage avec UTF8: namhv% 3A% 2F% 2Fcategory% 3Framegraph% 3D% E3% 83% AC% E3% 83% 93% E3% 83% A5% E3% 83% BC
(3) Chaîne reçue via l'intention: namhv: // catégorie? Category_name =% C3% A3% C6% 92% C2% AC% C3% A3% C6% 92% E2% 80% 9C% C3% A3% C6 % 92% C2% A5% C3% A3% C6% 92% C2% BC
(4) Chaîne après décodée avec UTF8: namhv: // catégorie nom_catégorie = レム« ム¥ ー Dans mon attente , (2) et (3) sont identiques, et (1) et (4) sont identiques. Mais je ne sais pas ce que Android fait avec de la ficelle lorsqu'il est passé via IntentFilter.