ACTION_SEND with Uri in data

FTP client for Android handsets.
Post Reply
mtotschnig
Posts: 3
Joined: Sat May 05, 2012 6:22 am
AntiSpam sum: 8

ACTION_SEND with Uri in data

Post by mtotschnig »

Hello,

in my application users can specify an FTP URI to upload a data file. Currently I handle the upload internally and that works well. But since only a tiny percentage of users need this feature, I plan to remove the ftp code, and call an external intent. I would like my users to be able to choose between potentially more than one app able to handle ftp uploads. Apps would need to react to ACTION_SEND with an ftp URI as data:

Code: Select all

intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setDataAndType(android.net.Uri.parse("ftp://user:pass@192.168.42.90"),"text/qif");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
context.startActivity(intent);
Currently AndFTP does not react to such an intent. Would it make sense for you to implement such a generic way of specifying an ftp upload intent?

Best regards,

Michael

mtotschnig
Posts: 3
Joined: Sat May 05, 2012 6:22 am
AntiSpam sum: 8

Re: ACTION_SEND with Uri in data

Post by mtotschnig »

I experimented with the idea and found out that instead of ACTION_SEND, one would need to use ACTION_SENDTO, since intent-filters for ACTION_SEND do not interprete the data. The following code:

Code: Select all

intent = new Intent(android.content.Intent.ACTION_SENDTO);
intent.setData(android.net.Uri.parse("ftp://user:pass@192.168.42.90"));
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
gets handled through the following intent filter:

Code: Select all

<intent-filter>
    <action android:name="android.intent.action.SENDTO"/>
    <data android:scheme="ftp"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>

support
Posts: 853
Joined: Sun Apr 20, 2008 4:40 pm

Re: ACTION_SEND with Uri in data

Post by support »

Intent to upload file is defined at:
http://www.lysesoft.com/products/andftp/intent.html

mtotschnig
Posts: 3
Joined: Sat May 05, 2012 6:22 am
AntiSpam sum: 8

Re: ACTION_SEND with Uri in data

Post by mtotschnig »

Hello,

I know that AndFTP has defined a special Intent for uploading files using the ACTION_PICK action and a custom data type. My question is if you'd agree to implement an Intent that would be coherent with how Android handles sending content through email, i.e. with action ACTION_SENDTO, specifying the URI with setData, and the file to send with Intent.EXTRA_STREAM, thus alowing applications to define sending through ftp in a generic way, and allowing users to choose the ftp client.
Sorry, if I did not make this sufficiently clear in my original post.

Regards,
Michael

Post Reply