Wednesday, February 27, 2013

Sending data from android to webserver using Post

Finally got the method form this  link, hopefully it will work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
     try {
        HttpClient client = new DefaultHttpClient();  
        String postURL = "http://somepostaddress.com";
        HttpPost post = new HttpPost(postURL); 
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("user""kris"));
            params.add(new BasicNameValuePair("pass""xyz"));
            UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
            post.setEntity(ent);
            HttpResponse responsePOST = client.execute(post);  
            HttpEntity resEntity = responsePOST.getEntity();  
            if (resEntity != null) {    
                Log.i("RESPONSE",EntityUtils.toString(resEntity));
            }
    } catch (Exception e) {
        e.printStackTrace();
    }

Wednesday, February 20, 2013

Message box and checking internet connection in andorid

In manifest file have to add a new permission
android.permission.ACCESS_NETWORK_STATE



ConnectivityManager cm =
       (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork.isConnectedOrConnecting();
if (isConnected != true){
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Ineternet Connection");
alertDialog.setMessage("Not available");
alertDialog.show();
}
else
{

// rest code
}

Pushing files in android /system/app folder


Pushing files in android /system/app folder(help got from this link)

Steps to follow
  1. Launch the emulator from the command line so that system folder should have free space.       emulator -avd test3 -partition-size 512                                              The emulator binary should be in  tools/ directory within your SDK link 
  2. Start the adb shell (command line for emulator) adb binary is in platform-tools                            adb shell (use df command to see the used and free space on partitions)
  3. Remount the system directory                                                                                                   mount -o remount, rw /system
  4. change the permission on the directory                                                                                      chmod 777 /system                                                                                                                 chmod 777 /system/app


Open the perspective in the eclipse, select File Explorer and then /system/app among folders. After selecting push the files in the folder using "Push files on the folder" button.