Learn Python


Click to Learn Python3

Sunday, July 31, 2011

Creating keystore and google api key for android google maps

Open the command prompt and follow the steps

D:\android-sdk-windows-1.6_r1\tools>keytool -genkey -v -keystore projectkey.keystore -alias aliasname -keyalg RSA -keysize 2048 -validity 15000
Enter keystore password: ------------
What is your first and last name?
[Unknown]: ------------
What is the name of your organizational unit?
[Unknown]: ------------
What is the name of your organization?
[Unknown]: ------------
What is the name of your City or Locality?
[Unknown]: ------------
What is the name of your State or Province?
[Unknown]: ------------
What is the two-letter country code for this unit?
[Unknown]: ------------

D:\android-sdk-windows-1.6_r1\tools>keytool -list -alias aliasname -keystore projectkey.keystore
Enter keystore password:
aliasname, Dec 7, 2010, PrivateKeyEntry,
Certificate fingerprint (MD5): CA:CF:AA:0E:5A:2B:88:C8:64:F1:FA:F7:29:21:50:FF

Using your Certificate fingerprint (MD5) get google api key from this site
http://code.google.com/android/maps-api-signup.html

Saturday, July 30, 2011

How to Install APK Files on Android Emulator using command prompt (cmd) without eclipse

Here we are going to see how to run (install) the apk file to the Android emulator without using eclipse.

Installing in different OS:

1. a Windows, Mac OS X (intel) or Linux (i386) powered computer
2. the Android Software Development Kit (SDK).


You do not need Eclipse or Eclipse-plugin the Android Development Tools (ADT). The last two are required for the software development for Android, but are not necessary for application evaluation on emulator.

First download the Android SDK, which may be obtained here: http://code.google.com/android/download.html

Follow the instruction, described in the topic "Installing SDK" from the Google manual, which is located here: http://code.google.com/android/intro/installing.html#installingsdk or you can go with http://android-codes-examples.blogspot.com/search/label/installation

Steps need to be followed:

Installing the SDK

After downloading the SDK, unpack the .zip archive to a suitable location on your machine. For the rest of this document, we will refer to the directory where you installed the SDK as $SDK_ROOT.

Optionally, you can add $SDK_ROOT/tools and $SDK_ROOT/platform-tools to your path:

On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look for a line that sets the PATH environment variable and add the full path to your $SDK_ROOT/tools to it. If you don't see a line setting the path, you can add one:

export PATH=${PATH}:
On a Mac, look in your home directory for .bash_profile and proceed as for Linux. You can create the .bash_profile, if you haven't already set one up on your machine.
On Windows, right click on My Computer, and select Properties. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up, double-click on Path under System Variables, and add the full path to the tools/ directory under $SDK_ROOT to it.

Adding $SDK_ROOT/tools to your path lets you run Android Debug Bridge (adb) and the other command line tools without needing to supply the full path to the tools directory. Note that, if you update your SDK, you should remember to update your PATH settings to point to the new location, if different.


-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Now navigate to the $SDK_ROOT/tools directory and execute the file 'emulator.exe'. This is the Android emulator itself. Wait couple of minutes until it loads. Now you must see the home screen of Android - wallpapers with snowy mountains on the background and the navigation bar below.

Enjoyed? Ok! Let's continue. Download and save locally a APK-file which you want to install/evaluate on the emulator. We recommend to save the APK file directly in the $SDK_ROOT/tools directory.

Note: APK probably stands for "Android package". It's an application distribution unit in the Android environment. If you are coming from the Windows Mobile world, think of APK as of CAB-files.

Ok, now start the console ("Start -> Run... -> type 'cmd'" for Windows computers). Type-in the following command: adb install $APK where $APK is the name of the APK file. For example: adb install Snake.apk

If you receive a "path not found" error, then you probably either didn't add path to the $SDK_ROOT/tools directory to your system PATH settings or the application you are trying to install is not in the $SDK_ROOT/tools or $SDK_ROOT/platform-tools directory.

If all went without errors then you should be seeing your newly installed APK on the emulator.

Monday, July 11, 2011

Design a linearlayout or textview and any component in android with border,corner radius and gradient

We can design a linearlayout or relativelayout or framelayout... or even we can design a text view with this coding. The sample is given for linear layout, the result will be like this

here i had given corner radius for left top corner and left bottom corner for the linear layout, and i applied border for whole linearlayout.

For design the layout we need to use this xml file


layout_border.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke android:width="2dp" android:height="2dp"
android:color="#FF0000" />
<solid android:color="#000000" />
<padding android:left="1dp" android:top="1dp" android:right="1dp"
android:bottom="1dp" />

<corners android:radius="1dp" android:bottomRightRadius="5dp"
android:bottomLeftRadius="0dp" android:topLeftRadius="5dp"
android:topRightRadius="0dp" />
</shape>
</item>

</layer-list>


and we need to set the xml file as background for the linear layout as


In the main xml
<LinearLayout android:layout_gravity="center"
android:layout_width="200dp" android:layout_height="200dp" android:background="@drawable/layout_border" />


For gradient effect you can use the below xml, this will not be in the source, you can put this file and set this as background for gradient effect


layout_gradient.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#ffa5ba"
android:endColor="#ff92af"
android:angle="150"/>

</shape>


The code is fulling checked so you can run the code after downloading it itself.

You can download the full source code


Download source


Have a good day.