open chrome with local file in android -


hello trying launch chrome app local file.html here code:

   string url2 = "file:///"         + environment.getexternalstoragedirectory().getabsolutepath()         + file.separator + "new folder"+ "/index.html";     url2  = url2 .replaceall(" ", "%20");     uri uri2 = uri.parse(url2 );        intent intent = new intent(intent.action_view, uri2);     intent.addflags(intent.flag_activity_new_task);     intent.setpackage("com.android.chrome");      try {       startactivity(intent);     } catch (activitynotfoundexception ex) {         intent.setpackage(null);       startactivity(intent);     } 

i open manually paste url in chrome works fine. when opening application opens text file html code not in chrome in text viewer

try this:

uri uri2 = uri.fromfile(new file(environment.getexternalstoragedirectory().getabsolutepath()     + file.separator + "new folder"+ "/index.html")); intent intent = new intent(intent.action_view, uri2); intent.addflags(intent.flag_activity_new_task); intent.setclassname("com.android.chrome", "com.google.android.apps.chrome.main");  try {     startactivity(intent); } catch (activitynotfoundexception ex) {     try {         intent.setpackage(null);         startactivity(intent);     } catch (exception e) {} } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -