A little coding help.....
This is a discussion on A little coding help..... within the Droid Development forums, part of the Droid Hacking category; So, I have an activity that has four buttons centered down a linear layout. Each button represents the file that i wish to download. Heres ...
-
A little coding help.....
So, I have an activity that has four buttons centered down a linear layout. Each button represents the file that i wish to download. Heres the java code:
PHP Code:
public class TwoActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.two);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendToUrl();
}
private void sendToUrl() {
// TODO Auto-generated method stub
String url = "downloadFileOne.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Button button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendToUrl();
}
private void sendToUrl() {
// TODO Auto-generated method stub
String url = "downloadFileTwo.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Button button3 = (Button) findViewById(R.id.button3);
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendToUrl();
}
private void sendToUrl() {
// TODO Auto-generated method stub
String url = "downloadFileThree.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Button button4 = (Button) findViewById(R.id.button4);
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendToUrl();
}
private void sendToUrl() {
// TODO Auto-generated method stub
String url = "downloadFileFour.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
}
}
The "String url =" has the web address of the download. However, this causes the browser to pop up and initiate the download, thus returning back to the activity. How do I go about downloading these files directly (maybe using downloadFromUrl as opposed to sendToUrl). I do not know how to implement downloadFrom.
Any help is greatly appreciated!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Similar Threads
-
By avatarhack in forum Droid General Discussions
Replies: 4
Last Post: 01-10-2011, 05:49 AM
-
By bill12690 in forum Droid Hacks
Replies: 3
Last Post: 05-26-2010, 02:11 AM
-
By Matth3w in forum Off Topic Forum
Replies: 5
Last Post: 03-06-2010, 06:18 PM
-
By Jen72386 in forum Droid General Discussions
Replies: 4
Last Post: 02-06-2010, 09:10 AM
-
By mrnelson86 in forum Droid Development
Replies: 22
Last Post: 01-21-2010, 09:16 PM
Search tags for this page
android sendtourl
,
coding foums for android
,
droid forums
,
i.setdata(uri.parse(url));
Click on a term to search our site for related topics.