以下のようなプログラムで、googleのトップページを表示できました。
//インテントでgoogleのトップページを表示
Intent intent =new Intent(
"android.intent.action.VIEW",
Uri.parse("http://www.google.com/"));
startActivity(intent);
また、自前でファイルを提供するコンテンツプロバイダ
(test.fileprovider)を作成し、以下のようなプログラムで
index.htmlを表示できることを確認しました。
//Webビューで表示
WebView webView=new WebView(this);
setContentView(webView);
webView.loadUrl("content://test.fileprovider/index.html");
そこで、インテントを用いてindex.htmlを表示させようと、
以下のようなプログラムを作成して実行したのですが、
//インテント
Intent intent =new Intent(
"android.intent.action.VIEW",
Uri.parse("content://test.fileprovider/index.html"));
startActivity(intent);
以下のようなエラーが出てForce closeさせられてしまいました。
The application FileProviderTest (process test.fileprovider)
has stopped unexpectedly. Please try again.
このようなインテントの使い方はできないのでしょうか?
AndroidSDKは2.2を使用し、動作環境はAndroid1.6、ApiLevel4です。
AVDのエミュレータでも実機(Xperia)でも同じ動作になりました。
自己フォローですが、エラーが出た部分を以下のように変更するとちゃんとindex.htmlが表示されました。
Intent intent =new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("content://test.fileprovider/index.html"),
"text/html");
startActivity(intent);
ACTIONとDATAだけではなく、TYPEも指定しなければいけなかったんですね。
すみません超初心者で・・・
#TYPEが不明な場合はあきらめるんですかね。
2010年7月18日14:10 <hiro...@gmail.com>: