Pankaj Khurana
Pankaj Khurana

Reputation: 3271

How do I perform an action on click of a particular link available on website?

I have an application in which I have added a menu.

Clicking on this menu opens up a website.

There is a list of links(zip files) available on this website.

Clicking on a particular link should result in that zip file to be downloaded to the assets folder of my application.

I am able to load the website.

Code for this:

String url = "http://almondmendoza.com/android-applications/";  
Intent k = new Intent(Intent.ACTION_VIEW);  
k.setData(Uri.parse(url));  
startActivity(k);    

I am referring to the example given on this website

What I am curious to know is whether it is possible to perform an action on click of a particular link available on the website. If it is possible then how can I accomplish this task?

Upvotes: 0

Views: 142

Answers (1)

Sandeep Kumar P K
Sandeep Kumar P K

Reputation: 7482

Use WebView to load webpage, you can recognize URL using following code

webView.setWebViewClient(new WebViewClient() { 
        public boolean shouldOverrideUrlLoading(WebView view, String url){
            webView.loadUrl(url); 
            // Here the String url hold 'Clicked URL' 
            return false; 
        } 
    });

Upvotes: 3

Related Questions