Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Linking Java to a website for android app

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Linking Java to a website for android app

    Hey guys, I think this is the best place to post this. Could not find any good site to ask this. But here goes,

    I am making a simple app, and I need the text to link to a webpage. The App randomly generates a set word each time the button is pressed. Here is the code.

    This is a small amount of the code but it continues down for about 30 more if else.

    			public void onClick(View arg0) {
    				// When the Button is Clicked
    			String answer = "";
     
    			//Random Answer Yes, No, or Maybe
    			Random randomGenerator = new Random();
    			int randomNumber = randomGenerator.nextInt(30);
     
    			if (randomNumber == 0) {
    				answer = "TEXT HERE!";
     
    			}
    			else if (randomNumber == 1) {
    				answer = "TEXT HERE!";
     
    			}
    			else if (randomNumber == 2) {
    				answer = "TEXT HERE!";
    			}
    			else if (randomNumber == 3) {
    				answer = "TEXT HERE!";
    			}

    how would I go about linking those words to a webpage? The links will be different though. So not all of the words will link to the same page.

    Thanks


  2. #2
    Junior Member
    Join Date
    Aug 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Linking Java to a website for android app

    You would need to add this to the button event:

    String url = "www.wherever.com"
    java.awt.Desktop.getDesktop().browse(java.net.URI. create(url));


    That SHOULD open up the url in the default browser.

Similar Threads

  1. Android Camera app
    By Yoyo_Guru in forum Android Development
    Replies: 1
    Last Post: July 26th, 2012, 01:47 PM
  2. Problem developing app for Android
    By jume28 in forum JDBC & Databases
    Replies: 1
    Last Post: June 4th, 2012, 05:26 PM
  3. Interested in developing an Android app eventually
    By madiaz3 in forum Member Introductions
    Replies: 1
    Last Post: May 17th, 2012, 07:02 AM
  4. Hello World Android App
    By TP-Oreilly in forum Android Development
    Replies: 6
    Last Post: January 22nd, 2012, 08:01 PM
  5. Any alternative of Eclipse for developing android app?
    By vincentroberts in forum Java IDEs
    Replies: 6
    Last Post: January 5th, 2012, 01:48 AM