How to activate a function only in developer mode

I have an application in application billing. I use AndroidBillingLibrary to control the purchase.

I would like to have access to all purchase options when I launch the application in debug mode.

Currently, when I need to check an option, I am replacing something like this:

bool option = BillingController.isPurchased(this,OPTION_NAME); 

by

 bool option = true;//BillingController.isPurchased(this,OPTION_NAME); 

Obviously, this is a bad decision!

Is something like that safe?

 public class MyApp extends Application { public static final bool DEBUG = true; } if(MyApp.DEBUG) option = true; else option = BillingController.isPurchased(this,OPTION_NAME); 

Is there a better solution? Thanks

+4
source share
1 answer

Get debug value using info info service.

 boolean DEBUG = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); 
0
source

Source: https://habr.com/ru/post/1397585/


All Articles