Wednesday, 12 September 2012

Draw a path between two Geo Points

Draw a line that between two points on Google Maps lets say City “A” and City “B”. Repeat the process to draw a line between City “B” and City “C”.
What we need:
Coordinates of 3 cities or any 3 locations that we want to connect.
  1. Abbottabad : 34159000,73220000
  2. Islamabad : 33695043,73050000
  3. Rawalpindi :33615043, 73050000
I have taken relative coordinates of 3 Pakistani cities starting from Abbottabad (where my family lives), moving to Islamabad (Capital of Pakistan). From Islamabad moving to Rawalpindi.

  • GeoPoint :An immutable class representing a pair of latitude and longitude, stored as integer numbers of microdegrees
  • Projection :A Projection serves to translate between the coordinate system of x/y on-screen pixel coordinates and that of latitude/longitude points on the surface of the earth.
  • Point :Converts the given GeoPoint to onscreen pixel coordinates, relative to the top-left of the MapView that provided this Projection 

    Here is the Screen: 

Monday, 3 September 2012

PopupWindow For Android

A popup window that can be used to display an arbitrary view. The popup windows is a floating container that appears on top of the current activity.Developer site link

Here we are using LayoutInflater for displaying the popupwindow objects. According to our requirements we will create the xml for popupWindow.

Here is the code lines:
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindow = new PopupWindow(



Wednesday, 25 July 2012

Upload apk into Android Market

Steps for Create a certificate for Android Market apk:

1.If you are using Eclipse for Development just right click on your project and click export.
2.Now choose Android and then Export Android Application. In the next step confirm the project that you want to export.
3.Then click next and now you should be able to select create new keystore.
4.Now fill in the required fields and your should be able to sign your app.
5. Be sure to make a backup of the keystore file and remember your password. Losing this will make it impossible to update your application.
6.If you are using the terminal to create a keystore and you have Java SDK installed there should be a program called keytool in /usr/bin (on a unix based system).
7.On Windows the SDK should also come with the keytool but the install location may be different search for keytool.exe on your computer if keytool is not in your path already. With this tool you should be able to create a key in the following way:
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000
8.Remember that once you lose your Certificate or it expires you will not be able to sign your application. Make sure that the expiration date is a long long time in the future. 
Reference sites: Link1
Publishing Updates on Android Market :

1.At any time after publishing an application on Android Market, you can upload and publish an update to the same application package.
2.When you publish an update to an application, users who have already installed the application may receive a notification that an update is available for the application. They can then choose to update the application to the latest version.
3.Before uploading the updated application, be sure that you have incremented the android:versionCode and android:versionName attributes in the element of the manifest file. Also, the package name must be the same as the existing version and the .apk file must be signed with the same private key.
Here we need to change:
Go to manifestfile and set the version code like this:
 <manifest xmlns:android=""
 android:versionName="2.0" >
 Here , old versioncode: 1  and new version code:2
4.If the package name and signing certificate do not match those of the existing version, Market will consider it a new application, publish it as such, and will not offer it to existing users as an update.
5.You have to have the same keystore file which you have used to upload the 1st version of application on android market. If you have lost this keystore file then you can't provide update to this application.
Note: Dont forgot to keep a backup of your keystore file.

Refered Links: Click Here

Thursday, 19 July 2012

Android Pdf Reader

This example shows you how to open a pdf file from your activity.
1.) Create a new project by File-> New -> Android Project name it PDFReader.
2.) You will see some default code into your main.xml and android manifest file.
3.) Download and install any adobe reader application from android market.
4.) Write following into main.xml file:

android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="PDFReader" />

5.) Copy any pdf file onto your sdcard.
6.) Make sure to change the name and path of your pdf file in PDFReaderActivity class. In this example I have used “/sdcard/sample.pdf” . You can change the name of your pdf instead of sample.pdf.
7.) Run for output.

Screen Shots: 

Here is Source Code: Download From Here

Wednesday, 18 July 2012

FacebookIntegration into android application

Steps for Facebook Integration in Android:
The Aim of this article is, to get Facebook integration into our Android Application.

1.Apply for a Facebook Application ID (APP_ID):
For this, we need a facebook account to create our own application.This link will help to create a new application in our account.Click Here
In this site, top corner of the right side, we have an option to create an application i.e
Create New App. Just click on that.. It moves to new window, and need to provide application name and namespace.
Next, it moves to the Our application information page. It contains the App ID , App secret ID and some basic Information.
Here is the screen shot: 
2. Include the Facebook APP_ID in your Android Application:
We need to include the APP_ID into our android application.
So far so good, everything is setup on the Facebook front, now it’s time to start coding our Android application.
On the Android front, we’ll use the Facebook Android SDK located at Github: DownLoad Here

The Facebook Android SDK is licensed under the Apache License and is completely 
open source.
The project contains several samples in the examples folder, but the core SDK is located in the facebook folder.

Here is the full source Code:SourceCode

3. Import the sdk into our application:
This sdk , we will import into our sample application for facebook intraction purpose.

This sdk contains 5 java classes, those are manage to intraction of facebook.

4. Our Sample Applicatoin:
Main page:
This page contains the login button. By using this, first we login to our facebook account.
Then after, in our application contains the few implementations to intraction with facebook. Those are:
                                   1. Update Status.
        1. App Requests
        2. Uploaded photos
        3. Get Friends
        4. Current Location
Few Screen Shots in our Application:
After Updating status in FB

Update Status

Login Screen
Main Page

Here is the Reference Link: Click Here