Monday, February 27, 2012

Create socail Network Contact Form in Android Application

Hi Friends,In this article I would like to explain the procedure of Creating a Contact Form in Android applications.Where we can share display facebook,twitter,linkedin and so on..at the same time we can display the location using Google maps.See the below picture.So lets start...



First We need to design a screen..Follow the steps




Create a new xml file and change the name as contact.xml

Next,add one new node called Linear Layout conside it as a parent Node.we need to add all the remaining child nodes inside this node







Next,create another two linear layouts inside the parent Linear layout node which split the screen in to two halves .one for Email entry form and another one for Google Maps and Social Network



 


 





Now Add the controls inside the First half LinearLayout inorder to create a Email Entry Form.

For Title : Address

 




Next,add the another linear layout below this Text view in order to arrange the controls in Horizontally

For Name :

 


 
       
  



For Email:

 
        
        
 


For Message :

 
        
        



For Send and cancel Buttons

 
       

So, First half part is completed.Now start the design of second part of the screen Add the Child linear Layout

 


For Heading : social Network





For Social Network Icons

 
      
          
           
 


For Google maps :

      
     
       
          


Note : In the Above Node You need to change the Api Key in order to access to google API.For further Details Please check the google maps Integration in Android applications article.

So finally Designing part is completed .Lets start the coding part

First ,Create a New Class and follow procedure

First,access the Images of social network

ImageView facebook=(ImageView) findViewById(R.id.facebook_image);
ImageView twitter=(ImageView) findViewById(R.id.twitter_image);
ImageView linkedin=(ImageView) findViewById(R.id.linkedin_image);


Next,Write the following code inorder to access the facebook using webview

facebook.setOnClickListener(new OnClickListener()
 {               
 public void onClick(View v) 
         {
  
   WebView fb_WebView = (WebView) findViewById(R.id.facebook_webview);
         fb_WebView.loadUrl("http://www.facebook.com/dotnettoolkit");
         fb_WebView.setWebViewClient(new WebViewClient()); 
         }

});


In the same way write for Twitter and Linkedin

Now ,coming to google Maps Integration inorder to display the Location

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,0, 

new GeoUpdateHandler());

public class GeoUpdateHandler implements LocationListener {

  public void onLocationChanged1(Location location) {
   int lat = (int) (location.getLatitude() * 1E6);
   int lng = (int) (location.getLongitude() * 1E6);   
   point = new GeoPoint(lat, lng);
   mapController.animateTo(point); 
   mapController.setCenter(point);
  }




Add the latitude and longtudinal values to display exact location.

For Brief tutorial of google maps integration check out this article

That's it...I hope this article will helps you

Labels: , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home