这里只说自定义文件,假设自定义文件后缀是.abc。
第一步:AndroidManifest启动页配置
-
- android:name="com.abc.MainActivity"
- android:label="@string/app_name"
- android:screenOrientation="portrait"
- android:windowSoftInputMode="adjustPan">
-
-
"android.intent.action.MAIN" /> -
"android.intent.category.LAUNCHER" /> -
-
"http"> -
"android.intent.action.VIEW" /> -
"android.intent.category.DEFAULT" /> - "*/*" />
- "*" />
- "file"/>
- "content"/>
- "http"/>
- "https"/>
- "/.*\\.abc" />
- "/.*\\..*\\.abc" />
- "/.*\\..*\\..*\\.abc" />
- "/.*\\..*\\..*\\..*\\.abc" />
- "/.*\\..*\\..*\\..*\\..*\\.abc" />
- "/.*\\..*\\..*\\..*\\..*\\..*\\.abc" />
- "/.*\\..*\\..*\\..*\\..*\\..*\\..*\\.abc" />
- "/.*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.abc" />
- "/.*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.abc/>
- " />
-
-
配置好这一步,在QQ或者微信或文件管理器打开.abc文件,选择“用其他应用打开”的时候列表就会出现你的app。
第二步:启动页获取文件路径。
- Intent intent = getIntent();
- String action = intent.getAction();
- if (intent.ACTION_VIEW.equals(action)) {
- Uri uri = intent.getData();
- String path = Uri.decode(uri.getEncodedPath());
- }
获取到文件路径就可以进行下一步处理了。