ユーザーに電話のギャラリーから画像を選択させようとしています。次に、webview を使用して画像を表示します。取得されるファイル パスは、「content://media/external/images/media/14」のようなものです。私が他の問題を見たとき、それらのファイルパスは通常「file://」で始まるようです
プログラムを実行すると、ランダムな文字の長いリストが表示されます。何が悪いのかわからない、助けていただければ幸いです。ありがとうございました
編集これは、Md Abdul Gafur のリンクによって解決されました。新しい修正コード:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
//message is the path of the file.
setContentView(R.layout.activity_picture_large);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setAllowFileAccess(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setBuiltInZoomControls(true);
String html = "<html><head></head><body><p>hello</p><img src=\"" + message + "\" alt=\"alternativo\" /></body></html>";
myWebView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
}