Integration of android application with facebook.

Thursday, September 27, 2012

This tutorial is about integrating facebook into your android application. I am going to explain various steps like generating your application signature, registering facebook application, downloading facebook sdk and other steps.

  • Generating App Signature for Facebook Settings

To create facebook android native app you need to provide your Android application signature in facebook app settings. You can generate your application signature (keyhash) usingkeytool that comes with java. But to generate signature you need openssl installed on your pc. If you don’t have one download openssl from here and set it in your system environment path.
Open your command prompt (CMD) and run the following command to generate your keyhash. While generating hashkey it should ask you password. Give password as android. If it don’t ask for password your keystore path is incorrect.

keytool -exportcert -alias androiddebugkey -keystore "<path-to-users-directory>\.android\
debug.keystore" | openssl sha1 -binary | openssl base64

check the following command how i generated hashkey on my pc.

keytool -exportcert -alias androiddebugkey -keystore "C:\users\raj\.android\debug.keystore"
| openssl sha1 -binary | openssl base64


Android kSoap2 web service parsing Data.


Android kSoap2 web service Parsing Data
In this tutorial for Android ksoap2 web service . we can passing data through web service and store the data in web server.
how to read and parse JSON or XML, but another (pretty big) format is SOAP. In this post we will see how you make a application that reads and parses SOAP data into a Android application!
first we need ksoap2-android-assembly-2.5.6-jar file. download this jar file and put your workspace lib folder.

  • Just click the most recent version
  • search for the jar file with dependencies.
  • download it by right clicking the link "Raw file"
  • then clicking "Save as ...".
  • Save it inside your project folder so you can link it easily. 
Note: add the jar file to the project. ( Project properties -> Java build path -> Add JAR's )

Source code :

Load images from server in android.

Wednesday, September 26, 2012

This tutorial demonstrates how to load a remote image into your application and bind this image to an ImageView object. HttpURLConnection is used to download the image data and BitmapFactory is used to produce the bitmap which will be used as ImageView resource.

Java Code :


import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

public class HTTPTest extends Activity {
     

     ImageView imView;
     String imageUrl="http://11.0.6.23/";
     Random r= new Random();
    /** Called when the activity is first created. */ 
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
       
        Button bt3= (Button)findViewById(R.id.get_imagebt);
        bt3.setOnClickListener(getImgListener);
        imView = (ImageView)findViewById(R.id.imview);
    }    

How to display images to gridview from server in android

Tuesday, September 25, 2012


This code is help you to display image in grideview from server in android.

ViewImage.java

package com.gridview;


import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.AdapterView;

import android.widget.GridView;

import android.widget.Toast;


public class MyGridView extends Activity {

    private GridView girGridView;

   @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);


        girGridView=(GridView) findViewById(R.id.gridView1_bir);


        girGridView.setAdapter(new ImageAdapter(this));


        girGridView.setOnItemClickListener(new AdapterView.OnItemClickListener()  {

       public void onItemClick(AdapterView<?> arg0, View view,                    int position,long arg3) {
      Toast.makeText(getApplicationContext(), GridViewConfig.getResim_list().
                 get(position), Toast.LENGTH_SHORT).show();

            }
        });

    }

}

Enable GPS programmatically in android.

Sunday, September 23, 2012


Here's some example code i use it help you.

private void turnGPSOn(){
    String provider = Settings.Secure.getString(getContentResolver(),
                      Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

    if(!provider.contains("gps")){ //if gps is disabled
        final Intent poke = new Intent();
        poke.setClassName("com.android.settings", "com.android.
          settings.widget.SettingsAppWidgetProvider"); 
        poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
        poke.setData(Uri.parse("3")); 
        sendBroadcast(poke);
    }
}