Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen browser to web page Android App
    primarykey
    data
    text
    <p>Trying to grasp Java and Android would like help with a simple task of opening a users browser after they click a button. </p> <p>I have been doing tutorials for the last two days though it might help if I just took a stab at it and got feedback. thanks in advance for any help.</p> <p>main.xml:</p> <pre><code>&lt;AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bgimage2"&gt; &gt; &lt;Button android:id="@+id/goButton" android:layout_width="150px" android:layout_height="wrap_content" android:text="@string/start" android:layout_x="80px" android:layout_y="21px" &gt; &lt;/AbsoluteLayout&gt; </code></pre> <p>GetURL.java:</p> <pre><code>package com.patriotsar; import android.app.Activity; import android.content.Intent; import android.view.View.OnClickListener; String url = "http://www.yahoo.com"; Intent i = new Intent(Intent.ACTION_VIEW); Uri u = Uri.parse(url); i.setData(u); public class patriosar extends Activity { private Button goButton; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); goButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v){ try { // Start the activity startActivity(i); } catch (ActivityNotFoundException e) { // Raise on activity not found Toast toast = Toast.makeText(context, "Browser not found.", Toast.LENGTH_SHORT); } } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload