由网友(愿望再失望)分享简介:这是我的清单文件。使用意图过滤器后,我从下载邮件附件的ICS文件。当我打开下载的文件就开始了我的申请。我需要的文件名,并在我的应用程序中选择文件的数据。我应该怎么做,在清单和Java文件。我很新到Android任何一个可以帮助我????<应用机器人:标签=@字符串/ APP_NAME机器人:图标=@可绘制/ ic...![如何获取当前活动的excel的文件名](https://p.xsw88.cn/allimgs/daicuo/20230906/1841.png)
这是我的清单文件。使用意图过滤器后,我从下载邮件附件的ICS文件。当我打开下载的文件就开始了我的申请。我需要的文件名,并在我的应用程序中选择文件的数据。我应该怎么做,在清单和Java文件。我很新到Android任何一个可以帮助我????
<应用机器人:标签=@字符串/ APP_NAME机器人:图标=@可绘制/ icsicon>
<活动机器人:名称=机器人setMIMEfile。:标签=@字符串/ APP_NAME>
<意向滤光器>
<作用机器人:名称=android.intent.action.VIEW/>
<类机器人:名称=android.intent.category.DEFAULT/>
<数据机器人:MIMETYPE =* / */>
<数据机器人:pathPattern = />中* 集成电路。
&所述; /意图滤光器>
< /活性GT;
解决方案
意向意图= getIntent();
字符串名称= intent.getData()getPath()。
![如何获取当前活动的excel的文件名](https://p.xsw88.cn/allimgs/daicuo/20230906/1841.png)
字符串名称将包含所选文件的路径,从该路径可以读取文件
This is my manifest file. After using intent filter i download the ics file from the mail attachment. When i open the downloaded file it start my application. I need to get the file name and data of the selected file in my application. What should i do in the manifest and the java file. I am very new to android can any one help me????
<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();
String name will contain your selected file path, from that path you can read your file
相关推荐
最新文章