How to launch browser to open local file

前端 未结 7 1273
孤街浪徒
孤街浪徒 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:52

    You need to add browsable category in the intent.

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    startActivity(intent);
    

提交回复
热议问题