Friday 26 April 2013

Display Android Google Map V2

==> Create New Application.
==> Install Google Play Serivces Library in to your application.
==> To Get Google Play Services you need to update your SDK with google play  services.
==> After that you need to add "google play services" library project in to your workspace ,after add into your application.
==> In your main.xml file write below code. 

  <fragment
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="300dp"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>


==> In your Main.Java Activity ,extends FragmentActivity ,define as below. 

public class MainActivity extends FragmentActivity {

    SupportMapFragment mMapFragment;
    GoogleMap mMap;
   
@Override
protected void onCreate(Bundle arg0) {
    // TODO Auto-generated method stub
    super.onCreate(arg0);
    setContentView(R.layout.main);
    mMap = ((SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
}
   
}


==> In your Manifest.xml file define some permissions and code for Map V2 as below.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mapv2demo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

     <permission
        android:name="com.example.mapv2demo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <uses-permission android:name="com.example.mapv2demo.permission.MAPS_RECEIVE" />
     <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
   
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_CORSE_LOCATION" />
 
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.mapv2demo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
         <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="Your API Key" />
    </application>

</manifest>
 
 
==> And Now run this application , it Display Google Map V2.  
 
   

Get Android Google Map Release Key

  1. Make One Folder in any drive. (i.e. Androidmapkey) 
  2. Copy your application keystore key , and Paste it in new created folder.
  3. Open Command Prompt.
  4. Go to your path "C:\Program Files (x86)\Java\jdk1.6.0_02\bin"
    After that write "keytool -v -list -keystore C:\"Your created folder" (i.e. AndroidMapKey)\your application keystore(i.e. demo.keystore)"  and press enter.
  5. In password give any password.
  6. It Create's Like defines as below.

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androiddebugkey
Creation date: Feb 20, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 5124695f
Valid from: Wed Feb 20 11:42:47 IST 2013 until: Fri Feb 13 11:42:47 IST 2043
Certificate fingerprints:
         MD5:  00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
         SHA1: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
         Signature algorithm name: SHA1withRSA
         Version: 3


*******************************************
*******************************************

 Using this MD5 and SHA1 Key Certificate you can take API Key.

Get Android Google Map Debug API Key

  1. Make One Folder in any drive. (i.e. Androidmapkey) 
  2. Copy your debug key from "C" Drive "Users" folder , and Paste it in new created folder.
  3. Open Command Prompt.
  4. Go to your path "C:\Program Files (x86)\Java\jdk1.6.0_02\bin"
    After that write "keytool -v -list -keystore C:\"Your created folder" (i.e. AndroidMapKey)\debug.keystore"  and press enter.
  5. In password give any password.
  6. It Create's Like defines as below.
 
*****************  WARNING WARNING WARNING  *****************
* The integrity of the information stored in your keystore  *
* has NOT been verified!  In order to verify its integrity, *
* you must provide your keystore password.                  *
*****************  WARNING WARNING WARNING  *****************

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androiddebugkey
Creation date: Feb 20, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 5124695f
Valid from: Wed Feb 20 11:42:47 IST 2013 until: Fri Feb 13 11:42:47 IST 2043
Certificate fingerprints:
         MD5:  00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
         SHA1: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
         Signature algorithm name: SHA1withRSA
         Version: 3


*******************************************
*******************************************

 Using this MD5 and SHA1 Key Certificate you can take API Key.

Find Hours Diffrence in Kotlin

  In Kotlin, determining the difference in hours between two timestamps is a common task, especially in scenarios involving time-based calcu...