How do you link a button to a website?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How do you link a button to a website?

Postby icow » Thu Oct 22, 2009 5:19 pm

title explains it i want a button to take em to a website how/??
icow
Freshman
Freshman
 
Posts: 8
Joined: Tue Aug 25, 2009 10:06 am

Top

Postby azraeal » Thu Oct 22, 2009 8:33 pm

In your button's click handler, start an activity with the following intent:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Intent i = new Intent();
  2.  
  3. i.setData(Uri.parse("http://yourUrlHere.com"));
  4.  
  5. myActivity.startActivity(i);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Postby icow » Thu Oct 22, 2009 9:18 pm

im a noob needs to be explained in more detail of what document to put this in ect or maybe is there an easier i am deving in eclipse if that helps
icow
Freshman
Freshman
 
Posts: 8
Joined: Tue Aug 25, 2009 10:06 am

Postby RS » Thu Oct 22, 2009 9:56 pm

Well, my 1st post... :)

Btw hello guys/anddev.org community!!

icow, you can try this way:

LinkButton.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package pt.rsdev.android.linkbutton;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.net.Uri;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.view.View.OnClickListener;
  9. import android.widget.Button;
  10.  
  11. public class LinkButton extends Activity {    
  12.     @Override
  13.     public void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.         setContentView(R.layout.main);
  16.        
  17.         Button btn = (Button) findViewById(R.id.btn_clickme);
  18.         btn.setOnClickListener(new OnClickListener() {
  19.                 public void onClick(View v) {
  20.                         Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
  21.                         myWebLink.setData(Uri.parse("http://www.anddev.org"));
  22.                         startActivity(myWebLink);
  23.                   }
  24.                 });
  25.     }
  26. }
  27.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


main.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:orientation="vertical"
  4.    android:layout_width="fill_parent"
  5.    android:layout_height="fill_parent"
  6.    >
  7.         <Button
  8.                 android:id="@+id/btn_clickme"
  9.                 android:text="Click me..."
  10.                 android:layout_width="fill_parent"
  11.                 android:layout_height="wrap_content"
  12.         />
  13. </LinearLayout>
  14.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
Code hard, go pro! Don't wait for someone to do your own project.
User avatar
RS
Junior Developer
Junior Developer
 
Posts: 11
Joined: Tue Oct 20, 2009 10:49 pm

Postby icow » Thu Oct 22, 2009 10:01 pm

where abouts does the java file goo sorry for my noobiness
icow
Freshman
Freshman
 
Posts: 8
Joined: Tue Aug 25, 2009 10:06 am

Postby RS » Thu Oct 22, 2009 10:17 pm

When you create a new project, you need to give a name... that name gonna be the main class name. Imagine that you create a new project with name "test", then your main java file gonna be test.java

I recomend you to check this link 1st, so you can understand what i'm saying:

Building your very first "Hello Android" - Application
Code hard, go pro! Don't wait for someone to do your own project.
User avatar
RS
Junior Developer
Junior Developer
 
Posts: 11
Joined: Tue Oct 20, 2009 10:49 pm

Top

Postby icow » Thu Oct 22, 2009 10:28 pm

ok thats good but i want the website to open up inside the app not the browser sorry being picky ino because the website is a video link its going to be an app kinda like the beebplayer one
icow
Freshman
Freshman
 
Posts: 8
Joined: Tue Aug 25, 2009 10:06 am

Postby RS » Thu Oct 22, 2009 10:39 pm

Code hard, go pro! Don't wait for someone to do your own project.
User avatar
RS
Junior Developer
Junior Developer
 
Posts: 11
Joined: Tue Oct 20, 2009 10:49 pm

Postby icow » Thu Oct 22, 2009 10:53 pm

only problem is its gonna be a live stream
icow
Freshman
Freshman
 
Posts: 8
Joined: Tue Aug 25, 2009 10:06 am

Postby icow » Thu Oct 22, 2009 11:06 pm

sorry mate that lnik only gives me the bare bones just need a little more info than that sorry to be a pain maybe you could help me
icow
Freshman
Freshman
 
Posts: 8
Joined: Tue Aug 25, 2009 10:06 am

Postby azraeal » Fri Oct 23, 2009 1:18 am

Sorry, but you've just hashed out several different topics and I don't believe in holding-your-hand-and-doing-it-for-you through all of it.

First: How to launch a web page.
Second: How to implement a click handler.
Third: How to embed a web view.
Fourth: How to play a web based video.

The first 2 points are already settled.

From what I've read, you don't even have a basic understanding of UI programming. Have you read Google's Dev Guide yet? Link

Third point: If you want to embed a webpage, just declare a WebView and add that to your layout. Then call webview.loadURL("http://icanhascheezburger.com/"); to load your web page into that web view. It's the same as adding any other view. You'll need to include the INTERNET permission in your manifest file. And before you ask, here's the explanation of the manifest file.

Fourth point: So the url you have ends in .3gp (as in, a mobile video file). Note that to a client, it doesn't matter if it's a live stream or a video-on-demand stream. They both point to an rtsp:// link (usually).
Like RS mentioned, read http://developer.android.com/guide/topi ... index.html
and then read http://developer.android.com/reference/ ... layer.html
or
http://developer.android.com/reference/ ... oView.html

Take a look at the ApiDemo's source files under com.example.Android.apis.media included with the Android library. The links are definitely NOT bare bones and they give you all the info you'd need to start.

Those are the best examples and reading you could be doing.

Now: here's the fun part about being a programmer (you are a programmer, right?). Take all the basic stuff you know from reading this, then find a way to combine them into a coherent package that does what you want it to do.
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Postby icow » Sat Oct 24, 2009 10:38 am

would like to thank you all for your help apps really coming together nicely

just one more thing

ok i have a few stream urls now but just need to check something the urls start with rtmp:// is this a correct format and they end with .sdp is this a correct format???
icow
Freshman
Freshman
 
Posts: 8
Joined: Tue Aug 25, 2009 10:06 am

Postby azraeal » Sun Oct 25, 2009 7:14 am

RTMP is a proprietary protocol less than 1 year old made by Adobe to stream to a FLASH player.

Android does not support flash at the moment (not that I know of).

The list of supported formats is listed here.

Make it simpler for yourself and have your streaming server serve via rtsp protocol. The *.sdp file itself should be fine.
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests