How to use Google Analytic for your app

Standard

Introduction

The Google Analytics SDK for Android makes it easy for developers to collect user engagement data from their apps. Developers can then use the Google Analytics app-tracking reports to measure:

  • The number of active users are using their applications.
  • From where in the world the application is being used.
  • Adoption and usage of specific features.
  • In-app purchases and transactions.
  • The number and type of application crashes.
  • And many other useful metrics.

Supporting Multiple Screens Using Drawables Different Density

Standard

Android supports several configuration qualifiers that allow you to control how the system selects your alternative resources based on the characteristics of the current device screen. A configuration qualifier is a string that you can append to a resource directory in your Android project and specifies the configuration for which the resources inside are designed.

How to access a string using a dynamic string name in android (similar to eval in javascript)?

Standard

You have to use “android.content.res.Resources.getIdentifier”.

Strings:
strCategory1
strCategory2
strCategory3

for (int i=0; i<n; i++){
 int resID = getResources().getIdentifier("strCategory" + position, "string", getPackageName());
 String strTest = getResources().getString(resID);
}

String Arrays:
strArray1
strArray2
strArray3

for (int i=0; i<n; i++){
 int resID = getResources().getIdentifier("strArray" + position, "array", getPackageName());
 String[] strArrayTest = getResources().getStringArray(resID);
}

Drawables:
ic_category1
ic_category2
ic_category3

for (int i=0; i<n; i++){
 int resID = getResources().getIdentifier("ic_category" + position, "drawable", getPackageName());
 imgIcon.setImageDrawable(getResources().getDrawable(resID));
}