Wednesday 22 February 2012

Simplest way to integrate Google Map in your android application.


To create google map in your android You should do these following steps.

STEP 1:-  create your activity

This is sample example:-
public class GooglemapActivity extends MapActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mMapView;
mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setBuiltInZoomControls(true);

}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}

STEP 2:- create googlemap in your main.xml file

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="your google map key"
/>

STEP 3:- make some entries in your android.menifest
these are:-

(a) Add the following as a child of the <application> element:

<uses-library android:name="com.google.android.maps" />

(b) add the following as a child of the <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />

STEP 3:- make your debug.keystore key

for windows users we have our default debug.keystore in C:\Documents and Settings\user\.android

(a) open your command prompt and run command
 cd C:\Documents and Settings\user\.android

(b) then run this command
     keytool -list -keystore debug.keystore
   it will ask for password then enter password : android
(c) It will generate a key, note this key for future use.

STEP 4:- register your application with google, please visit this link:- http://code.google.com/android/maps-api-signup.html
(a) accept terms and conditions, enter your key which is generated on command prompt
(b) Press Generate API key
(c) It will generate an API key, use this key in your application xml.

STEP 5:- CLEAN AND BUILD YOUR PROJECT , IT WILL SHOW YOU GOOGLE MAP.

I hope this will help you alot, BEST OF LUCK.

Note:- If any query then feel free to ask me anytime @ kuntal.pushpendra@gmail.com

Sunday 13 November 2011

How can send email in php from your localhost.

This is code which can be used to send email from your local host.


<?php
 require_once "Mail.php";

 $from = "Sender <puskun.pericent@gmail.com>";
 $to = "Recipient <kuntal.pushpendra@gmail.com>";
 $subject = "Hi!";
 $body = "Hi,\n\nHey Kuntal, you done it...";

 //$host = "mail.example.com";
 $host = "smtp.gmail.com";
 $username = "your usename for smtp server";
 $password = "your password for smtp server";

 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'auth' => true,
     'username' => $username,
     'password' => $password));

 $mail = $smtp->send($to, $headers, $body);

 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }

 ?>