Solved

Android send data via web page URL

Posted on 2014-03-05
3
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

If your app took Google’s lash recently, here are the 5 most likely reasons.
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
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.

707 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