Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to get the file name from Intent?

wmckessonwmckesson USMember
edited June 2013 in Xamarin.Android

Here is the AndroidManifest.xml. After setting the intent filter, I download an *.xyz file from e-mail attachment. When I open the downloaded file, it starts my app.

However, I need to get the file name of the downloaded file.

<application android:label="@string/app_name" android:icon="@drawable/myicon">
    <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=".*\\.xyz" />    
     </intent-filter>
</activity>

I found this sample code but it is based on Java. What is the equivalent for Xamarin? I try Intent.Data.GetPath() but GetPath() is not a valid method.

Intent i = getIntent();    
String path = i.getData().getPath(); // String path contains the selected file path

Please advise.

Posts

  • DWestyDWesty USMember ✭✭
    edited June 2013

    Try
    this.Intent.Data.Path

    from your activity

  • wmckessonwmckesson USMember

    Unfortunately, this.Intent.Data.Path returns "/1/5/RAW" instead of the downloaded file name such as myfile.xyz.

Sign In or Register to comment.