User click on .txt file in file explorer and get dialog "Open with..." and there is listed my app. When I try to open file I want to get its absolute path. All I get is content:// URI
I/ActivityManager: START u0 {act=android.intent.action.VIEW dat=content://com.android.providers.downloads.documents/document/1031 typ=text/plain
If I want to retrieve path to my file I need to get file:// URI. How can I get only file://
URI instead of content://
?
Here is AndroidManifest
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*"/>
</intent-filter>
Here is how I try to handle file:
Intent i = getIntent();
String action = i.getAction();
String type = i.getType();
if (Intent.ACTION_VIEW.equals(action) && type != null) {
Uri uri = i.getData();
if (uri != null) {
Toast.makeText(this, uri.toString(), Toast.LENGTH_SHORT).show();
}
}