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 ...

+ Reply to Thread
Results 1 to 1 of 1

Thread: A little coding help.....

  1. Theme Developer
    johnnyb15613's Avatar
    Member #
    59596
    Join Date
    Apr 2010
    Posts
    290
    Liked
    11 times
    Phone
    Galaxy Nexus
    DroidForums.net Theme Developer
    #1

    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 = (ButtonfindViewById(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 = (ButtonfindViewById(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 = (ButtonfindViewById(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 = (ButtonfindViewById(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!
  2. Sponsor
    DF Advertising
    Join Date
    Nov 2008
    Location
    DroidForums.net
     
     
     
     

Sponsors

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Similar Threads

  1. Coding on the go
    By avatarhack in forum Droid General Discussions
    Replies: 4
    Last Post: 01-10-2011, 05:49 AM
  2. Need some help! coding/theming..
    By bill12690 in forum Droid Hacks
    Replies: 3
    Last Post: 05-26-2010, 02:11 AM
  3. Please help with coding
    By Matth3w in forum Off Topic Forum
    Replies: 5
    Last Post: 03-06-2010, 06:18 PM
  4. color coding calendars
    By Jen72386 in forum Droid General Discussions
    Replies: 4
    Last Post: 02-06-2010, 09:10 AM
  5. Developing and Coding
    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.