Back to project page callerid-for-android.
The source code is released under:
GNU General Public License
If you think the Android project callerid-for-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.integralblue.callerid.inject; /*from w w w . ja va 2 s . c o m*/ import android.os.Build; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Provider; import com.integralblue.callerid.contacts.ContactsHelper; public class ContactsHelperProvider implements Provider<ContactsHelper> { @Inject Injector injector; public ContactsHelper get() { final String className; final int sdkVersion = Integer.parseInt(Build.VERSION.SDK); if (sdkVersion < Build.VERSION_CODES.ECLAIR) { className = "OldContactsHelper"; } else { className = "NewContactsHelper"; } try { final Class<? extends ContactsHelper> clazz = Class.forName(ContactsHelper.class.getPackage().getName() + "." + className) .asSubclass(ContactsHelper.class); final ContactsHelper ret = clazz.newInstance(); injector.injectMembers(ret); return ret; } catch (Exception e) { throw new IllegalStateException(e); } } }