Solved

Android send data via web page URL

Posted on 2014-03-05
3
229 Views
Last Modified: 2014-10-23
Is there sample code that when a button is click the on click listener will raise an intent to launch an activity to to post data to a web page URL
0
Comment
Question by:GlobaLevel
3 Comments
 
LVL 2

Accepted Solution

by:
Computer Egghead earned 500 total points
ID: 40266189

1. Add a button in your layout file with:

android:onClick="onOpenWebBrowser"

Open in new window


2. Import the following packages:

import android.net.Uri;
import android.content.Intent;

Open in new window


3. Add the following code:

    //Opens a web page when a button is clicked
    public void onOpenWebBrowser(View v)
    {
    	Intent webPageIntent = new Intent(Intent.ACTION_VIEW);
    	webPageIntent.setData(Uri.parse("http://www.computeregghead.com"));

    	try { 
    	    startActivity(webPageIntent);
    	} catch (ActivityNotFoundException ex) { 
    	    // do something about the exception 
    	}
    }

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
A short article about a problem I had getting the GPS LocationListener working.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question