Can anyone give me an idea on how to create a textview which has a link and when the user click it, the file from that link will be automatically downloaded by the device
EDIT:
here's the code were working on:
String link = "http://www.exampleurl.com/"+pref.getString("fsfile" + count, null);
link = link.replaceAll(" ", "%20");
fsfile.setText("Attached File");
fsfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// starting new Async Task
new DownloadFileFromURL().execute(link);
}
});
but it seems the String link
is not identified inside the .setOnClickListener
Please use the below code onclick of TextView:
DownloadFromURL.java
Thats quite easy http://developer.android.com/reference/android/app/DownloadManager.html
Example: http://androidtrainningcenter.blogspot.co.at/2013/05/android-download-manager-example.html
And start this method after clicking the textview (Catch with Handler or listener)
But be sure you are min. on API 9