public class Myintent {
Android gets a intent to open the HTML file
public static Intent gethtmlfileintent (String param) {
Uri uri = uri.parse (param). Buildupon (). Encodedauthority ("Com.android.htmlfileprovider"). Scheme ("content"). Encodedpath (param). build ();
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.setdataandtype (URI, "text/html");
return intent;
}
Android gets a intent to open the picture file
public static Intent getimagefileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addcategory ("Android.intent.category.DEFAULT");
Intent.addflags (Intent.flag_activity_new_task);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "image/*");
return intent;
}
Android gets a intent to open the PDF file
public static Intent getpdffileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addcategory ("Android.intent.category.DEFAULT");
Intent.addflags (Intent.flag_activity_new_task);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "application/pdf");
return intent;
}
Android gets a intent to open the text file
public static Intent gettextfileintent (String param, Boolean Paramboolean) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addcategory ("Android.intent.category.DEFAULT");
Intent.addflags (Intent.flag_activity_new_task);
if (Paramboolean) {
Uri uri1 = uri.parse (param);
Intent.setdataandtype (Uri1, "Text/plain");
} else {
Uri uri2 = uri.fromfile (new File (param));
Intent.setdataandtype (Uri2, "Text/plain");
}
return intent;
}
Android gets a intent to open the audio file
public static Intent getaudiofileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addflags (Intent.flag_activity_clear_top);
Intent.putextra ("OneShot", 0);
Intent.putextra ("Configchange", 0);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "audio/*");
return intent;
}
Android gets a intent to open the video file
public static Intent getvideofileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addflags (Intent.flag_activity_clear_top);
Intent.putextra ("OneShot", 0);
Intent.putextra ("Configchange", 0);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "video/*");
return intent;
}
Android gets a intent to open the CHM file
public static Intent getchmfileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addcategory ("Android.intent.category.DEFAULT");
Intent.addflags (Intent.flag_activity_new_task);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "Application/x-chm");
return intent;
}
Android gets a intent for opening Word files
public static Intent getwordfileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addcategory ("Android.intent.category.DEFAULT");
Intent.addflags (Intent.flag_activity_new_task);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "Application/msword");
return intent;
}
Android gets a intent that opens an Excel file
public static Intent getexcelfileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addcategory ("Android.intent.category.DEFAULT");
Intent.addflags (Intent.flag_activity_new_task);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "application/vnd.ms-excel");
return intent;
}
Android gets a intent for opening PPT files
public static Intent getpptfileintent (String param) {
Intent Intent = new Intent ("Android.intent.action.VIEW");
Intent.addcategory ("Android.intent.category.DEFAULT");
Intent.addflags (Intent.flag_activity_new_task);
Uri uri = uri.fromfile (new File (param));
Intent.setdataandtype (URI, "Application/vnd.ms-powerpoint");
return intent;
}
}
Open various types of files with intent