skill paper

  • paper
Showing posts with label N.P.Prabakaran. Show all posts
Showing posts with label N.P.Prabakaran. Show all posts

Tuesday, August 14, 2012

Showing current location map

map.java

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
 
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
 
public class LocationBasedServicesV1 extends MapActivity {
 
	private MapView myMap;
 
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
 
		initMap();
		initMyLocation();
	}
 
	/**
	 * Initialise the map and adds the zoomcontrols to the LinearLayout.
	 */
	private void initMap() {
		myMap = (MapView) findViewById(R.id.mymap);
 
		View zoomView = myMap.getZoomControls();
		LinearLayout myzoom = (LinearLayout) findViewById(R.id.myzoom);
		myzoom.addView(zoomView);
		myMap.displayZoomControls(true);
 
	}
 
	/**
	 * Initialises the MyLocationOverlay and adds it to the overlays of the map
	 */
	private void initMyLocation() {
		MyLocationOverlay myLocOverlay = new MyLocationOverlay(this, myMap);
		myLocOverlay.enableMyLocation();
		myLocOverlay.enableCompass();
		myMap.getOverlays().add(myLocOverlay);
 
	}
 
	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
}



main layout:



  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:enabled="true"
    android:id="@+id/mymap"
    android:apiKey=" mapskey" />
  
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/myzoom"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
  />

set user permission:
  INTERNET 
   LOCATION.
 version="1.0" encoding="utf-8"?>

	xmlns:android="http://schemas.android.com/apk/res/android"
	package="de.itemis.frey.blog.lbsv1"
	android:versionCode="100"
	android:versionName="1.0.0">
	
		android:icon="@drawable/icon"
		android:label="@string/app_name">
		
			android:name=".LocationBasedServicesV1"
			android:label="@string/app_name">
			
				 android:name="android.intent.action.MAIN" />
				 android:name="android.intent.category.LAUNCHER" />
			
android:name="com.google.android.maps" /> android:name="android.permission.INTERNET" /> android:name="android.permission.ACCESS_FINE_LOCATION" /> Screen shot:


Wednesday, August 8, 2012

Passing value between activity:

Class1.java
    Intent intt=new Intent();
intt.putExtra("keyto call",value to pass);
startAcivity(intt);

key : which used to refer value in another actvity.
Class2.java

Bundle bun=Intent.getExtra();
String gh=bun.toString("Keyto call");


Saturday, August 27, 2011

Map for Beginners

Sample map:
       Create new project,(file->new->androis project).
     Add permission to access internet in manifestXml.
    
    
    

   Next edit main.xml:
             
  ?xml version="1.0" encoding="utf-8"?>  
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"> 
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
com.google.android.maps.MapView>

      android:id="@+id/mapview"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:clickable="true"
    android:apiKey="Your Maps API Key" />


Iam Sure your u have Api key...

    1. public class HelloMapView extends MapActivity {}
                                           - extend mapActivity instead od Activity .
     2. protected boolean isRouteDisplayed()
{
   
return false;//override this into false
}


      3.initialize below in oncreate()
     mapView = (MapView) findViewById(R.id.mapview);
     mapView
.setBuiltInZoomControls(true);


NOW RUN IT....
you seem to get like this

Generally Map Load from USA and BRASIL.you can change the to your location....
for your query post me here,