How to launch browser to open local file

前端 未结 7 1272
孤街浪徒
孤街浪徒 2020-12-10 05:20

I\'m trying to send intent to browser to open local file. I wish to use default browser to open this file.

if(file.exists()){
  Log.d(TAG, \"file.exists\");         


        
7条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 05:59

    Maybe this works:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "text/html");
    startActivity(intent);
    

提交回复
热议问题