Wednesday, September 28, 2011

How to get your MD5 Fingerprint for Android using Eclipse Keytool Plugin

If you're looking for easier ways to get your MD5 fingerprint without using the command line or terminal, then might as well follow this tutorial.

Get MD5 Fingureprint for Google Map.



Thursday, September 22, 2011

How To Enable the Android Market in the Google Android Emulator

If you want to enable the android market in android emulator then please follow the below link . There you can find great tutorial about android market on emulator.

Install Android Market on Emulator.

Saturday, September 17, 2011

Check Airplane Mode

Below function checks weather your device is in Airplane Mode or Not
*******************************************************************

public boolean isAirplaneMode(Context context)
{
int settingValue;
try
{
settingValue = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON);
return settingValue != 0;
} catch (SettingNotFoundException e)
{
return false;
}
}

Get Ip Address of device

Below function returns the Ip Address of Android Device
*******************************************************

public String getLocalIpAddress() {
try {
for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e(LOG_TAG, ex.toString());
}
return null;
}

Show all running Service in android

Below Code shows all the running service .

ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List rs = am.getRunningServices(50);

for (int i=0; i {
ActivityManager.RunningServiceInfo
rsi = rs.get(i);
Log.i("Service", "Process " + rsi.process + " with component " + rsi.service.getClassName());
}

Friday, September 16, 2011

Calculate Total External Storage memory

StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount();
long megAvailable = bytesAvailable / 1048576;

Here megAvailable display total External Storage Memory

Calculate Available External Storage memory

StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getFreeBlocks() * (long)stat.getBlockSize();;
long megAvailable = bytesAvailable / 1048576;

Here megAvailable display available External Storage Meomry

Calculate Total Internal Storage memory

StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount();
long megAvailable = bytesAvailable / 1048576;

Here megAvailable display total Internal Storage Memory

Calculate Available Internal Storage memory

StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
long bytesAvailable = (long)stat.getFreeBlocks() * (long)stat.getBlockSize();;
long megAvailable = bytesAvailable / 1048576;

Here megAvailable display available Internal Storage Memory

Load Image From Url

Below function load image from web url and return drawable.

public static Drawable LoadImageFromWebOperations(String url)
{
try
{
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
}
catch (Exception e)
{
return null;
}
}