Showing posts with label How to. Show all posts
Showing posts with label How to. Show all posts

How to verify your app is installed from Play Store

Android provides a way to determine whether our app is installed via playstore or by any other appliaction. It would be very handy in case if we need to perform any action only when its a valid play store build and to ignore when its a debug build or a direct apk install from any apk sharing applications

 Android's PackageManager class helps us to identify the application that installed our app. Lets see how its done.

How to enable USB debugging mode in Jelly Bean - Android 4.2 and above Devices



In devices like Nexus 4,Nexus 7,Nexus 10 and other Android 4.2 plus devices the developer options is hidden. To make them appear in your Settings you should enable it first

Follow these steps to enable developer options:

1.Go to “Setting” in your device and tap on it.
2.Scroll down to “About Phone” and tap on it.
3.Now scroll to the bottom to find “Build Number” and tap on it 7 times ( Yeah 7 times)

If you have done it you will get a pop-up message saying “You are now a developer”. Thats it!!!

You can now see the Developer options in Settings where you can find USB Debugging.

How to get Google Map API Key for Android

Now I will explain how to get Google Map API key for Android Application Development. To do this first we should know where the debug.keystore  reside in your system.

Getting the 'debug.keystore' path:

To find it , In Eclipse navigate to Windows->Preferences->Android->Build Her you will find the path near Default Debug Keystore:"C:\Users\<your_name>\.android\debug.keystore"

Getting the 'MD5 Certificate Fingerprint':

Now that you have the keystore path we are ready to get the MD5 Certificate Fingerprint . Open Command Prompt (type cmd in run and press enter) and navigate to Program Files (x86)\Java\jre6\bin
and type the command keytool -list -alias androiddebugkey -keystore "C:\Users\<your_name>\.android\debug.keystore" -storepass android -keypass android and press enter.
You will be given a Certificate Fingerprint like 2G:54:39:DB:23:E7:D7:3A:9E:18:3D:7F:FB:6D:BC:9D

Refer the below Image for reference:












.

Getting the API Key:

Now that we have got the Certificate Fingerprint log in to your Google Account and open the link ->
https://developers.google.com/android/maps-api-signup

Read the terms and conditions accept it and paste the MD5 Fingerprint in the textbox and click Generate API key button. You will be given an API key like 0XQpOUpGrVszoIS6vgtJ6oSdcYj1wRHnxj_4EHg 

Paste the API key in your layout file where MapView is used:


<com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="0XQpOUpGrVszoIS6vgtJ6oSdcYj1wRHnxj_4EHg "
        android:clickable="true"
         />

Note : The Map would be shown only in the Emulator in the computer where you generate the finger print since this is a debug key.If you wish to show map in different devices generate the key using the applications publishing keystore.

How to disable Japanese / Chinese keyboard suggestions in Android Emulator

If the android emulator suggests Japanese or Chinese words when you type in English and you want to disable it then just uncheck the Japanese  IME / Chinese IME in settings.

This is how its done:

Navigate to Settings->Language & Keyboard -> Japanese  IME (uncheck it!!)

The same can be done to disable Chinese suggestions also.

Android - Adding Image, Text and Background to a Button

To have a button with image, text and background in android . Edit the button tag on the .xml file as follows

Sample:
<Button
    android:id="@+id/ButtonTest"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/ic_btn_bg"
    android:drawableTop="@drawable/ic_btn_img"
    android:text="My Button"
    android:textColor="#FFFFFF" >

</Button>

Here the above sample code is to align the image on top of the text in a button. It is also possible to align the image to the right ,left and bottom of the text by using
android:drawableBottom/Rigth/Left="@drawable/ic_btn_img"