Posts

Showing posts from 2010

Simple animation in android

Hi, here is a way to create a very simple animation in android. Probably you know that there are tow types of animations in android. 1. tween animation and 2. Frame animation I'm describing a simple example of tween animation. Let's start. suppose we have a ImageView on a LinearLayout. we want to create a animation so that the image will move from a point to another point. First we have to create a xml file in the res/layout folder in which we'll show the image. It may be something like this - <?xml version="1.0" encoding="utf-8"? > < LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:layout_gravity="center" android:layout_height="fill_parent" android:layout_width="fill_parent" > < ImageView android:background="@drawable/animtest" android:layout_w

to get email address from the addressbook in android

courtesy to http://www.anddev.org/viewtopic.php?p=19672 first add uses_permissions for reading contacts in the manifest file. then add this code inside any function(i.e onCreate() of activity) Uri mContacts = Contacts.ContactMethods.CONTENT_URI; String[] projection = new String[] { Contacts.ContactMethods.PERSON_ID, Contacts.ContactMethods.DISPLAY_NAME, Contacts.ContactMethods.KIND, Contacts.ContactMethods.DATA }; Cursor c = this.managedQuery(mContacts, projection, null, null, Contacts.ContactMethods.DISPLAY_NAME + " ASC"); c.moveToFirst(); int previousId = -1; do { int personId = c.getInt(c .getColumnIndex(Contacts.ContactMethods.PERSON_ID)); if (personId != previousId) { String personName = c.getString(c .getColumnIndex(Contacts.ContactMethods.DISPLAY_NAME)); Log.i("name",personName); } int dataKind = c.getInt(c .getColumnIndex(Contacts.ContactMethods.KIND)); if (dataKind == 1) { String personE