Introduction To Google Android Application Development
Introduction To Google Android Application Development
Google Map.
To integrate with Google maps application you need to apply for a free Google Map API Key. To get the Google Map API Key you need to sign up for the Android Maps API. To sign up, you will need to provide the certificates fingerprint (MD5). If you have a certificate fingerprint (MD5) you can sign up here and get the API Key.
You need to get the keystore file for getting the certificate fingerprint (MD5). Your keystore file can be found at the following path
"64:88:A2:FC:AA:9F:B1:B0:CA:E4:D0:24:A8:1E:77:FB"
Click here to go for sign up page to get Google Map API Key. Enter the MD5 certificate fingerprint in the textbox and get the API Key (see below image)
After clicking the Generate API Key Button , you will get Google Map API Key (red circled).
Now the sample xml layout code to use the Google map application in Android is as specified below Coding:To use Google map in your application, you need to add <uses-library> element together with the <usespermission> in AndroidManifest.xml file. Now your AndroidManifest.xml code looks like
01 <?xml version="1.0? encoding="utf-8??> 02 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 03 package="pack.sample.map" 04 android:versionCode="1? 05 android:versionName="1.0?> 06 <application android:icon="@drawable/icon" android:label="@string/app_name"> 07 <uses-library android:name="com.google.android.maps" /> 08 <activity android:name=".SampleMapApplication" 09 android:label="@string/app_name"> 10 <intent-filter> 11 <action android:name="android.intent.action.MAIN" /> 12 <category android:name="android.intent.category.LAUNCHER" /> 13 </intent-filter> 14 </activity> 15 </application> 16 <uses-permission android:name="android.permission.INTERNET"/> 17 </manifest>
To display map in your application, modify the main.xml file. It is located in <project-folder>/res/layout.
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi
Use <com.google.android.maps.MapView> element to display map. Now your main.xml code looks like
01 <?xml version="1.0" encoding="utf-8"?> 02 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 03 android:layout_width="fill_parent" 04 android:layout_height="fill_parent"> 05 <com.google.android.maps.MapView 06 android:id="@+id/mapView" 07 android:layout_width="fill_parent" 08 android:layout_height="fill_parent" 09 android:enabled="true" 10 android:clickable="true" 11 android:apiKey="0U7-rnRk3Os0sPZnZF9iejONnHMsGRLxU0JbrBg"/> 12 </RelativeLayout>
Now run the application, you should be able to see the Google Map
Status Bar.
Hiding the title bar & status bar is used in gaming applications to show full screen to user. Hide the Status bar through code
01 @Override 02 public void onCreate(Bundle savedInstanceState) { 03 04 05 06 07 08 09 10 11 12 } setContentView(R.layout.tabs1); // Hide the Status Bar getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); // Hide the Title Bar requestWindowFeature(Window.FEATURE_NO_TITLE);
After,
To set an icon in the title bar use the below piece of code
1 @Override 2 public void onCreate(Bundle savedInstanceState) { 3 super.onCreate(savedInstanceState); 4 requestWindowFeature(Window.FEATURE_RIGHT_ICON); 5 setContentView(R.layout.main); 6 setFeatureDrawableResource(Window.FEATURE_RIGHT_ICON, R.drawable.icon); 7}
By using this code we can get the output as shown in the below image