Previous file sharing, this article about opening files, file open mode selection, and select our own app is to get the file to be processed.
To make our own app appear in the file open mode, just set up the manifest file Androidmanifast.xml, add a <intent-filter> under <activity>
<Intent-filter> <ActionAndroid:name= "Android.intent.action.VIEW"></Action> <DataAndroid:mimetype= "Text/comma-separated-values" /> <categoryAndroid:name= "Android.intent.category.DEFAULT"></category></Intent-filter>
You must create a new <intent-filter> here, or you will get an error. Here is an example of the error:
< Intent-filter > < android:name= "Android.intent.action.MAIN"/> < android:name= "Android.intent.category.LAUNCHER"/></ Intent-filter >
This is the main startup item of the program, if we add a mimetype under this <intent-filter> tag, the program runs completely without exception, but the icon to open the app is missing.
Here the mimetype write is our file format, here is the CSV so fill "text/comma-separated-values".
After processing the file, get the parameters by intent
Intent mintent = getintent (); String action = mintent.getaction (); If (Textutils.equals (Action, Intent.action_view)) { uri uri = mintent.getdata (); if (Textutils.equals (Uri.getscheme (), "file")) {
String path = Uri.getpath ();
}
}
You can do all kinds of things by getting the file path.
Android Add file opening method and parameter passing