Solved

Android send data via web page URL

Posted on 2014-03-05
3
227 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
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.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

772 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