Saturday, October 29, 2011

Enable SD card app storage option in android handset


You can now move most if your installed App into SD memory. Doing this technique you will be enabled to install lot of android apps in to your phone.

This technique is also a solution for "low internal memory" error in your handset.

Hacking technique:
* install android sdk with "google usb driver" selected in your computer
* connect your android phone to the computer using usb
* open command promt and cd to android-sdk/platform-tools
* type cmd "ade devices" will show the android devices connected in the system
* type below command to enable app install in SD card
"adb shell pm setInstallLocation 2"

(*Note)if you want to revert back to the default installtion path then type command like below
"adb shell pm setInstallLocation 0"

Once you have done this, goto your android phone and navigate to Settings -> Applications -> manage Apllication and click on your applications like to move to SD card and now you can see "move on Sd card" button is enabled.

Solution for Out Of Memory Error and recycled bitmap Exception


Using bitmapDrawable.getBitmap().recycle() may clear all the memory cached by your ImageView object and avoid the situation where Out Of Memory Error occurs, it is very useful while dealing with large images. Non proper usage of this method will cause  Exception: java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@405a8818.


Solution:
This exception occurs when you try to recycle a bitmap which is already recycled. You should not remove bitmap.recycle() function from your existing code, it may cause Out Of Memory Error. You can try this below code to fix the issue.

    BitmapDrawable bitmapDrawable = ((BitmapDrawable) profileWallpaper.getDrawable());
   
    if (null != bitmapDrawable && bitmapDrawable.getBitmap().isRecycled()) {
   
bitmapDrawable.getBitmap().recycle();
  } else {
   
log("bitmap is already recycled");
     }
   
      bitmapDrawable = null;

*Note: profileWallpaper is your imageView object*