January 17th, 2011, 04:26 AM
Over Macho Grande?
Join Date: Nov 2009
Device(s): GlassXE, MotoX, N5, N4, N7'12, GNex, N1, SGT10.1, Revue, Xoom, Eris, OG Droid
Thanked 3,537 Times in 1,507 Posts
Without actually reading the file into memory I'd say the best was to determine the mime-type is based on extension, so yeah you're probably stuck with a hard-coded lookup, then call myIntent.setType("text/html"); or whatever.
File root = Environment.getExternalStorageDirectory();
File myFile = new File(root, "whatever.html");
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setType("text/html"); //this is where you will have to hardcode
i.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile( myFile ));
startActivity(Intent.createChooser(i, "Choose program") );