Friday, December 11, 2015

keepclasseswithmembernames and keepclasseswithmembers difference

Some of the important attributes in proguard project properties include

-keep attribute
can be used with class, inteface enum etc

eg: -keep class com.smartandroidians.views.FloatingActionButtonBehavior which is not used in any java class and only used in xml files just like a string as

app:layout_behavior="com.smartandroidians.views.FloatingActionButtonBehavior"

proguard remove this class because it feels like it is not used anywhere but it is a very important class  for the app rather floating button to function.

Solution.
1) You can do something like this,
-keep class com.smartandroidians.views.FloatingActionButtonBehavior { *; }

or rather better approach is

2) -keepclasseswithmembernames class * {
    public (android.content.Context, android.util.AttributeSet);
}

How to get the package name of default sms app


Code snippet for getting the default package name of SMS

for below kitkat

String defApp = Settings.Secure.getString(getContentResolver(), "sms_default_application");
PackageManager pm = getApplicationContext().getPackageManager();
Intent iIntent = pm.getLaunchIntentForPackage(defApp);
ResolveInfo mInfo = pm.resolveActivity(iIntent,0);
Log.i(TAG, "apk:"+mInfo.activityInfo.packageName);
above or equal to kitkat

Telephony.Sms.getDefaultSmsPackage(this)


SQLite no concept of boolean - stored as 0 or 1

A simple but useful

SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).

Eg:
select * from table where deleted='false' which is wrong instead you have to write 
select * from table where deleted=0

Androidians