0
我有一个应用程序应该能够打开并从电子邮件中读取文本文件。 我改变了我的清单以下从uri获取文件名和路径作为文本文件
<activity
android:name="FileLoaderActivity"
android:label="@string/fileloader_title"
android:parentActivityName="MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
在我FileLoaderActivity我见的onCreate方法中以下内容:
// Get the intent that started this activity
Intent intent = getIntent();
Uri data = intent.getData();
//Verify that the type is text file
if (intent.getType().equals("text/plain")) {
String path = data.getPath();
File file = new File(path);
Toast.makeText(getApplicationContext(), path,Toast.LENGTH_SHORT).show();
if(file.exists())
Toast.makeText(getApplicationContext(), "I exist",Toast.LENGTH_SHORT).show();
}
现在输出如下:
/MY_EMAIL @ gmail.com/messages/78/attachments/0.1/BEST/false
和“我存在”永远不会出现。因此,这不会打开文件当然 我已经阅读了很多其他的解决方案,但他们似乎是媒体的具体。 能否请你帮我把实际的文件路径,
非常感谢你提前