Monday, November 21, 2011

Mobile Payments Library for Android

The PayPal Mobile Payments Library lets you accept PayPal payments within your mobile app. A buyer stays in your app while logging in to PayPal, reviewing a purchase, and completing a payment. The library provides the buyer's shipping, billing, and payment information to your app.

Please click here  for library and source code .

Thursday, November 3, 2011

Get SIM card number

 TelephonyManager teleManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
 String simNo = teleManager .getSimSerialNumber();

You also need to provide android.permission.READ_PHONE_STATE permission in android manifest file.

Saturday, October 22, 2011

Uninstall Apps from device using Intent.

You can uninstall App from device using following code.

Uri packageURI = Uri.parse("package:com.any.app");
startActivity(new Intent(Intent.ACTION_DELETE, packageURI));



Monday, October 17, 2011

Android Screencast for displaying device screen on computer

Android screen cast can display my Android device (phone or tablet) on a computer screen . It works on my HTC Legend running Android 2.2 .

The screencast will display the device screen on the computer. For rooted ROM, you can also use the computer keyboard and mouse to control the device.It doesn’t handle device screen rotation at all. So phone will display in portrait mode only and tablet in landscape mode only.

Apart from the above, it is a great tool when doing presentation with Android devices. Plug and USB cable and run the software and your audience will be able to see your device screen. No more messy setup of a separate overhead projection unit. And the display quality is way better.

You can Download the Screen Cast from Here.




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;
}
}