Android: Activity not found exception on some devices, when trying to open local HTML - file in browser

前端 未结 5 1024
忘了有多久
忘了有多久 2020-12-29 12:51

I\'m encountering a strange error when I try to open a local HTML - file in the android browser. The error that occurs is an activity not found exception:

an         


        
5条回答
  •  灰色年华
    2020-12-29 13:28

    Why not leave it to the system to determine which app to use? If I have (for example) Chrome installed and perfer to use Chrome, I'll be a bit pissed that you forced the default browser on me.

    This should work:

    final Uri uri = Uri.parse(filePath);
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
    browserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
    context.startActivity(browserIntent);
    

提交回复
热议问题