Saturday, August 20, 2011

Get Android phone call history/log programmatically

To get call history programmatically first add read conact permission in Manifest file :
<uses-permission android:name="android.permission.READ_CONTACTS" />

Create xml file. Add the below code in xml file :

<Linearlayout android:layout_height="fill_parent"
 android:layout_width="fill_parent"
android:orientation="vertical">
<Textview android:id="@+id/call"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</Textview>
</Linearlayout>

Now call the getCallDetails() method in java class :

private void getCallDetails() {

StringBuffer sb = new StringBuffer();
Cursor managedCursor = managedQuery( CallLog.Calls.CONTENT_URI,null, null,null, null);
int number = managedCursor.getColumnIndex( CallLog.Calls.NUMBER );
int type = managedCursor.getColumnIndex( CallLog.Calls.TYPE );
int date = managedCursor.getColumnIndex( CallLog.Calls.DATE);
int duration = managedCursor.getColumnIndex( CallLog.Calls.DURATION);
sb.append( "Call Details :");
while ( managedCursor.moveToNext() ) {
String phNumber = managedCursor.getString( number );
String callType = managedCursor.getString( type );
String callDate = managedCursor.getString( date );
Date callDayTime = new Date(Long.valueOf(callDate));
String callDuration = managedCursor.getString( duration );
String dir = null;
int dircode = Integer.parseInt( callType );
switch( dircode ) {
case CallLog.Calls.OUTGOING_TYPE:
dir = "OUTGOING";
break;

case CallLog.Calls.INCOMING_TYPE:
dir = "INCOMING";
break;

case CallLog.Calls.MISSED_TYPE:
dir = "MISSED";
break;
}
sb.append( "\nPhone Number:--- "+phNumber +" \nCall Type:--- "+dir+" \nCall Date:--- "+callDayTime+" \nCall duration in sec :--- "+callDuration );
sb.append("\n----------------------------------");
}
managedCursor.close();
call.setText(sb);
}

Using this application user can access his call history. It show call number,call type i.e. incoming/outgoing/missed call, call date-time and call duration.
Here is the output where user can see all details :







Thursday, July 28, 2011

Delete contacts from Android device

We can delete the contacts from android device programmatically.

Declare the permissions in manifest file:



Using Android 1.6 :
getContentResolver().delete(Contacts.People.CONTENT_URI,null,null);

Using Android 2.0 and above:
getContentResolver().delete(ContactsContract.RawContacts.CONTENT_URI,null,
null);

Wednesday, June 22, 2011

Installed application information in Android

Using PackageManager we can get the all installed application details in Android device like package name,version code,version info,class name etc.

Code snippet:

PackageManager pckMgr;
pckMgr = getPackageManager();
List appInfo = pckMgr.getInstalledPackages(PackageManager.GET_ACTIVITIES);
Log.i("Number of Applications are installed " ,":"+ appInfo.size());
for ( int cnt=0; cnt < appInfo.size(); cnt++){

Log.i("Package name ",":"+appInfo.get(cnt).packageName);
Log.i("Application name ",":"+appInfo.get(cnt).applicationInfo.loadLabel(getPackageManager()));
Log.i("Version code ",":"+appInfo.get(cnt).versionCode);
Log.i("Version name ",":"+appInfo.get(cnt).versionName);

}

Tuesday, February 2, 2010

Android based Acer Liquid Launched in India

Acer Liquid launcehed in India with Android1.6 high defination smartphone.
It is VGA smartphone with latest Android1.6 OS.
Features :
multimidia
web browsing
video streaming
smart integration of Facebook, Twitter, Youtube, Picasa and Flickr in the address book
MP3 (MP3/WAV/WMA/eAAC+ player)
MP4 (MP4/WMV/H.264/H.263 player)
messaging (SMS (threaded view), MMS, Email, Instant Messaging)
browser (HTML)
memory of 256MB RAM
512MB ROM
microSD card slot of up to 32GB.
3.5mm audio jack
vibration
WAV ringtones
3G (HSDPA 7.2 Mbps, HSUPA 2.0 Mbps) enabled phone
weighs 135g with 115 x 62.5 x 12.5 mm dimensions
5-megapixel camera
GPS
HSDPA connectivity
RS.24,990 with 2GB micro-SD

Monday, February 1, 2010

Android available with 'Deposit@Mobile' App

Good news for Android users. According to MobileMag, Google Android Nexus One users, and other Android smartphone users will be able to use the ‘Deposit@Mobile’ app to deposit checks into their account without ever having to go to the bank again.

Apparently, users are required to be pre-qualified by their branch and take a picture of the front and back of an endorsed check and then submit the image to their account info.

Seemingly, the app comes equipped with a few extra features of an ATM Locator to find the closest ATM’s, a detailed accident checklist, a loan calculator which will estimate either car or mortgage payments, and a car rental locator for the nearest Avis, Budget, or Hertz.

Reportedly, users must be running Android 1.6 or higher in order to use the app. The pricing details of the app are quite bleary for now.