gpt4 book ai didi

android - 如何从 Intent 中获取文件名?

转载 作者:可可西里 更新时间:2023-11-01 18:50:00 25 4
gpt4 key购买 nike

这是我的 list 文件。使用 intent 过滤器后,我从邮件附件中下载了 ics 文件。当我打开下载的文件时,它会启动我的应用程序。我需要在我的应用程序中获取所选文件的文件名和数据。我应该在 list 和 java 文件中做什么。我是 android 的新手,有人可以帮助我吗????

<application android:label="@string/app_name" android:icon="@drawable/icsicon">
<activity android:name=".setMIMEfile" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.ics" />
</intent-filter>
</activity>

最佳答案

Intent intent = getIntent();                
String name = intent.getData().getPath();

字符串名称将包含您选择的文件路径,您可以从该路径读取您的文件

关于android - 如何从 Intent 中获取文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2971871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com