0x01 功能

实现在其他应用中打开某个后缀名的文件 可以直接跳转到本应用中的某个activity进行处理

0x01 实现

首先创建一个activity ,然后在manifest里对该activity项编辑,加入

这里定义的是以.file为后缀的文件,需要对自己需要的后缀名进行修改,其中pathPattern可以设置为多个,用于应对各种情况,

完善后如下

android:screenOrientation="portrait"

android:label="固件升级"

>

android:name="android.intent.action.VIEW" />

android:name="android.intent.category.DEFAULT" />

android:pathPattern="/.*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\.res" />

android:pathPattern="/.*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\..*\.res" />

android:name="android.intent.action.VIEW" />

android:name="android.intent.category.DEFAULT" />

android:pathPattern="/.*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\..*\.fw" />

android:pathPattern="/.*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\..*\.ft" />

android:pathPattern="/.*\..*\.res" />

android:pathPattern="/.*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\.res" />

android:pathPattern="/.*\..*\..*\..*\..*\..*\..*\..*\..*\..*\.res" />

android:name="android.intent.action.VIEW" />

android:name="android.intent.category.DEFAULT" />

android:mimeType="application/octet-stream" />

android:name="android.intent.action.VIEW" />

android:name="android.intent.category.DEFAULT" />

android:mimeType="application/zip" />

android:mimeType="application/x-zip-compressed" />

android:name="android.intent.action.SEND" />

android:name="android.intent.category.DEFAULT" />

可以直接从intent中拿到文件的路径

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_update_fw);

super.setTitle("res/fw 安装器");

Intent v3=this.getIntent();

String v1 = v3.getDataString();

Toast.makeText(UpdateFwActivity.this,v1,Toast.LENGTH_LONG).show();

}

0x03 效果

6ac59f0bfc339fb106c25ec82b315247.png

5aac247d084deaac52a44b6779350e16.png

参考:

https://github.com/Freeyourgadget/Gadgetbridge/blob/master/app/src/main/AndroidManifest.xml

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐