Hi,

Romain Guy in a recent twitter mentionned the
overridePendingTransition which is api level 5 :
http://d.android.com/reference/android/app/Activity.html#overridePendingTransition(int,%20int)

Api level 5 is Android 2.0.

To use this function only if it exists in order to maintain Android
1.5 compatibility you need to look at the getMethod/invoke pattern.

For example, I use it to check if there is multitouch support (api
level 5 as well).

First you check if a method exists in a particular class using
getMethod wich throws a NoSuchMethodException if it's not found :
try {
        getPointerCountMethod=MotionEvent.class.getMethod("getPointerCount",
int.class);
}
catch (SecurityException e)
{multiTouchExistInSdk=false;e.printStackTrace();}
catch (IllegalArgumentException e)
{multiTouchExistInSdk=false;e.printStackTrace();}
catch (NoSuchMethodException e)
{multiTouchExistInSdk=false;e.printStackTrace();}

Then later on when you want to actually use the method in your code :

if (multiTouchExistInSdk) {
  multitouchSdkObject=getGetPointerCountMethod.invoke(event);
  int numberOfPointers=((Number)multitouchSdkObject).intValue();
}

Hope that helps.

Yahel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to