Wednesday, October 4, 2017

Monday, October 2, 2017

Android Common Code

All the common android code list that used almost every android project.

Here is the list of all code in this post:
  • Support vector drawable
  • PreferenceFragment support
  • Java 8 support
Support vector drawable:
to support vector drawable add below line on the build.gradle file
compile 'com.android.support:support-vector-drawable:26.1.0'
also adds below line on those activities where you use vector drawable.
static {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

PreferenceFragment support:
add the following line on the build.gradle file
compile 'com.android.support:preference-v14:26.1.0'
adds also add below line on the style.XML file
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
note: This line is for Material Theme support.

Java 8 support:
to support Java 8 add following line on the build.gradle file
// Keep the following configuration in order to target Java 8.
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}