Using Intent to go to a geo location : Location « Hardware « Android

Home
Android
1.2D Graphics
2.Animation
3.Core Class
4.Database
5.Date Type
6.Development
7.File
8.Game
9.Hardware
10.Media
11.Network
12.Security
13.UI
14.User Event
Android » Hardware » Location 
Using Intent to go to a geo location
 


package app.test;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.Toast;

class MyBrowserActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.row);
    Uri url = getIntent().getData();
    WebView webView = (WebViewfindViewById(R.id.WebView01);
    webView.setWebViewClient(new Callback());
    webView.loadUrl(url.toString());
  }
  private class Callback extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      return (false);
    }
  }
}
public class Test extends Activity {

  Button b1, b2, b3, b4, b5;
  int request_Code = 1;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    b1 = (ButtonfindViewById(R.id.btn_webbrowser);
    b1.setOnClickListener(new OnClickListener() {
      public void onClick(View arg0) {
        Intent i = new Intent("android.intent.action.VIEW");
        i.setData(Uri.parse("http://www.amazon.com"));
        startActivity(i);
      }
    });
    b2 = (ButtonfindViewById(R.id.btn_makecalls);
    b2.setOnClickListener(new OnClickListener() {
      public void onClick(View arg0) {
        Intent i = new Intent(android.content.Intent.ACTION_CALL, Uri.parse("tel:+651234567"));
        startActivity(i);
      }
    });
    b3 = (ButtonfindViewById(R.id.btn_showMap);
    b3.setOnClickListener(new OnClickListener() {
      public void onClick(View arg0) {
        Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri
            .parse("geo:37.827500,-122.481670"));
        startActivity(i);
      }
    });
    b4 = (ButtonfindViewById(R.id.btn_chooseContact);
    b4.setOnClickListener(new OnClickListener() {
      public void onClick(View arg0) {
        Intent i = new Intent(android.content.Intent.ACTION_PICK);
        i.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
        startActivityForResult(i, request_Code);
      }
    });

    b5 = (ButtonfindViewById(R.id.btn_launchMyBrowser);
    b5.setOnClickListener(new OnClickListener() {
      public void onClick(View arg0) {
        Intent i = new Intent("app.test.MyBrowser", Uri
            .parse("http://www.amazon.com"));
        i.addCategory("app.test.OtherApps");
        i.addCategory("app.test.SomeOtherApps");
        startActivity(i);
      }
    });
  }

  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == request_Code) {
      if (resultCode == RESULT_OK) {
        Toast.makeText(this, data.getData().toString(),
            Toast.LENGTH_SHORT).show();
        Intent i = new Intent(android.content.Intent.ACTION_VIEW,
            Uri.parse(data.getData().toString()));
        startActivity(i);
      }
    }
  }
}

//main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
<Button
    android:id="@+id/btn_webbrowser"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Web Browser" />    
<Button
    android:id="@+id/btn_makecalls"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Make Calls" />   
<Button
    android:id="@+id/btn_showMap"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Show Map" />    
<Button
    android:id="@+id/btn_chooseContact"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Choose Contact" />
<Button
    android:id="@+id/btn_launchMyBrowser"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Launch My Browser" />
    
</LinearLayout>
//row.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
<WebView 
    android:id="@+id/WebView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" />
</LinearLayout>

   
  
Related examples in the same category
1.Location service and LocationManager
2.Location service
3.Using LocationManager
4.My location
5.Display GEO location
6.Using location service for the weather
7.Location based service
8.My location and Google Map
9.Custom Location Overlay
10.Get my location
11.Geo location and Google Map
12.Location Tracking
13.A light pool of objects that can be resused to avoid allocation.
14.extends android.location.Location
15.Geo Location Util
16.C:\Java_Dev\WEB\dev\android\weatherforecastsystem-read-only\com\hci\pwf\LocationUtil.java
17.upload Data with Geo location
18.Copy a file from one location to another.
19.LocationManager.GPS_PROVIDER
20.Location util
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.