horin
horin

Reputation: 1654

Android FTP Intent

I am developing an app which transfers files to and from Android Wear watch by using FTP server running on watch. Right now I connect devices to same network by creating hotspot on smartphone. Then FTP server is started on watch and smartphone can connect to it. The problem is that I want to create som simple and universal app to connect from smartphone. However hotspot uses DHCP and I cant asign static IP to watch so I want to create only small app for smartphone which creates something like FTP intent and then some file explorer should open this intent. For example I prepare intent lik:

String url="ftp://user:[email protected]:21"
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

but I am getting no activity to handle intent found exception with es file explorer and also solid file explorer installed. I have tried using AndFTP which provides very good intent documentation but it wasn't very stable. Do you have any idea if ES file explorer or something similar can accept intent to open ftp connection?

Upvotes: 2

Views: 1192

Answers (1)

Shreyash S Sarnayak
Shreyash S Sarnayak

Reputation: 2335

I don't know about ES File Explorer or any other app but I found it could be done using chrome with a little hack. By using google chrome's navigator.

    String url = "ftp://user:[email protected]:21";

    String uri = "googlechrome://navigate?url=" + url;
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(uri));

    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.setPackage("com.android.chrome");

The last 2 lines are to open intent specifically in chrome.

I hope this solves your problem.

Upvotes: 1

Related Questions