Example usage for android.content.pm ApplicationInfo FLAG_DEBUGGABLE

List of usage examples for android.content.pm ApplicationInfo FLAG_DEBUGGABLE

Introduction

In this page you can find the example usage for android.content.pm ApplicationInfo FLAG_DEBUGGABLE.

Prototype

int FLAG_DEBUGGABLE

To view the source code for android.content.pm ApplicationInfo FLAG_DEBUGGABLE.

Click Source Link

Document

Value for #flags : set to true if this application would like to allow debugging of its code, even when installed on a non-development system.

Usage

From source file:com.lillicoder.newsblurry.util.FileLogger.java

/**
 * Determines if this app is running in debug mode. This value is
 * automatically set via the build process.
 * @return <code>true</code> if the app is running in debug mode,
 *          <code>false</code> otherwise.
 *//*from ww w.  j a  v  a 2  s .  c om*/
private boolean isDebugMode() {
    boolean isDebugMode = false;

    Context context = this.getContext();
    PackageManager packageManager = context.getPackageManager();
    try {
        ApplicationInfo appInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
        isDebugMode = (0 != (appInfo.flags &= ApplicationInfo.FLAG_DEBUGGABLE));
    } catch (NameNotFoundException e) {
        Log.e(TAG, String.format(WARNING_FAILED_TO_GET_APPLICATION_INFO, context.getPackageName()));
    }

    return isDebugMode;
}

From source file:com.landenlabs.all_devtool.DevToolActivity.java

@SuppressLint("DefaultLocale")
@Override/*  w  w  w  .ja v a  2  s.  co  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    m_uncaughtExceptionHandler = new UncaughtExceptionHandler();
    boolean DEBUG = (getApplicationInfo().flags & 2) != 0;
    AppCrash.initalize(getApplication(), DEBUG);

    GlobalInfo.s_globalInfo.mainFragActivity = this;
    try {
        GlobalInfo.s_globalInfo.isDebug = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
        GlobalInfo.s_globalInfo.pkgName = getPackageName();
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        GlobalInfo.s_globalInfo.version = pInfo.versionName;
        // GlobalInfo.s_globalInfo.appName = pInfo.applicationInfo.name;
    } catch (Exception ex) {
        GlobalInfo.s_globalInfo.version = "1.3";
    }

    /*
    // See build.gradle to add
    // debugCompile "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
    if (GlobalInfo.s_globalInfo.isDebug) {
    LeakCanary.install(this.getApplication());
    }
    */

    JodaTimeAndroid.init(this); // Load TimeZone database.
    GoogleAnalyticsHelper.init(this);
    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
    Utils.onActivityCreateSetTheme(this);

    setContentView(R.layout.main);
    setTitle(String.format("%s v%s API=%d", GlobalInfo.s_globalInfo.appName, GlobalInfo.s_globalInfo.version,
            Build.VERSION.SDK_INT));
    // setTitle(GlobalInfo.s_globalInfo.appName + " v" + BuildConfig.VERSION_NAME + " API" + Build.VERSION.SDK_INT +  (BuildConfig.DEBUG ? " Debug" : ""));

    // Initialization
    ViewPager viewPager = Ui.viewById(this, R.id.pager);
    GlobalInfo.s_globalInfo.tabAdapter = new TabPagerAdapter(getSupportFragmentManager(), viewPager,
            getActionBar());

    GlobalInfo.grabThemeSetings(this);

    GoogleAnalyticsHelper.event(this, this.getLocalClassName(), "create", "");

    Intent intent = this.getIntent();
    if (intent != null) {
        String startupFrag = intent.getStringExtra(GlobalInfo.STARTUP_FRAG);
        if (!TextUtils.isEmpty(startupFrag)) {
            m_startFrag = startupFrag;
        }
    }

    if (!TextUtils.isEmpty(m_startFrag)) {
        viewPager.setCurrentItem(GlobalInfo.s_globalInfo.tabAdapter.findFragPos(m_startFrag, 0));
    }
}

From source file:com.skwas.cordova.appinfo.AppInfo.java

public boolean getIsDebuggable() {
    return 0 != (_appInfo.flags &= ApplicationInfo.FLAG_DEBUGGABLE);
}

From source file:com.wikitude.virtualhome.AugmentedActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_augmented);

    this.setTitle("AR Virtual Home");

    markerPresent = getIntent().getStringExtra("MarkerPresent");
    imagePath = getIntent().getStringExtra("ImagePath");
    productID = getIntent().getStringExtra("productid");
    PastTransaction = getIntent().getStringArrayExtra("PastTransaction");
    System.out.println("array length" + PastTransaction.length);

    Log.e(TAG, "VIRTUALHOME: User has marker?" + markerPresent);
    Log.e(TAG, "VIRTUALHOME: User selected image path:" + imagePath);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }//from   w  w  w.  j a  va  2s  .  c o m
    }

    this.architectView = (ArchitectView) this.findViewById(R.id.architectView);

    //      To use the Wikitude Android SDK you need to provide a valid license key to the onCreate lifecycle-method of the ArchitectView.
    //      This can either be done directly by providing the key as a string and the call the onCreate(final String key) method or creating an
    //      StartupConfiguration object, passing it the license as a string and then call the onCreate(final StartupConfiguration config) method.
    //      Please refer to the AbstractArchitectCamActivity of the SDK Examples project for a practical example of how to set the license key.
    final StartupConfiguration config = new StartupConfiguration(WIKITUDE_5_0_SDK_KEY,
            StartupConfiguration.Features.Tracking2D, StartupConfiguration.CameraPosition.BACK);
    try {

        this.architectView.onCreate(config);

    } catch (RuntimeException rex) {
        this.architectView = null;
        Toast.makeText(getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT).show();
        Log.e(this.getClass().getName(), "VIRTUALHOME: Exception in ArchitectView.onCreate()", rex);
    }

    Log.e(this.getClass().getName(), " VIRTUALHOME: Assigning UrlListener");

    // set urlListener, any calls made in JS like "document.location = 'architectsdk://foo?bar=123'" is forwarded to this listener, use this to interact between JS and native Android activity/fragment
    this.urlListener = this.getUrlListener();

    // register valid urlListener in architectView, ensure this is set before content is loaded to not miss any event
    if (this.urlListener != null && this.architectView != null) {
        Log.e(this.getClass().getName(), " VIRTUALHOME: Call registerUrlListener");
        this.architectView.registerUrlListener(this.urlListener);
    }
}

From source file:es.ugr.swad.swadroid.modules.Module.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Check if debug mode is enabled

    try {/*from   w  ww  .j  av a  2s .  c  o m*/
        getPackageManager().getApplicationInfo(getPackageName(), 0);
        isDebuggable = (ApplicationInfo.FLAG_DEBUGGABLE != 0);
    } catch (NameNotFoundException e1) {
        e1.printStackTrace();
    }

    // Initialize webservices client
    webserviceClient = null;

    super.onCreate(savedInstanceState);

    // Recover the launched async task if the activity is re-created
    connect = (Connect) getLastNonConfigurationInstance();
    if (connect != null) {
        connect.activity = new WeakReference<Module>(this);
    }
}

From source file:com.inovex.zabbixmobile.push.NotificationService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    String status, message, source;
    Long triggerid;//from w  ww.j  a v  a  2  s . co m

    if (intent != null) {

        status = intent.getStringExtra("status");
        message = intent.getStringExtra("message");
        triggerid = intent.getLongExtra("triggerid", 0);
        createNotification(status, message, triggerid);

        source = intent.getStringExtra("source");
        // only log if we are running in debug mode
        // http://stackoverflow.com/questions/7022653/how-to-check-programmatically-whether-app-is-running-in-debug-mode-or-not
        if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) {
            logNotification(status, message, triggerid, source);
        }
    }

    return super.onStartCommand(intent, flags, startId);
}

From source file:de.htw.ar.treasurehuntar.AbstractArchitectActivity.java

/**
 * Called when the activity is first created.
 *///w  w w  . ja v a 2s.co m
@SuppressLint("NewApi")
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // pressing volume up/down should cause music volume changes
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    this.setContentView(this.getContentViewId());
    this.setTitle(this.getActivityTitle());

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Log.i("architect", "create");

    mGestureDetector = createGestureDetector(this);

    //
    // this enables remote debugging of a WebView on Android 4.4+ when debugging = true in AndroidManifest.xml
    // If you get a compile time error here, ensure to have SDK 19+ used in your ADT/Eclipse.
    // You may even delete this block in case you don't need remote debugging or don't have an Android 4.4+ device in place.
    // Details: https://developers.google.com/chrome-developer-tools/docs/remote-debugging
    //
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    // set AR-view for life-cycle notifications etc.
    this.architectView = (ArchitectView) this.findViewById(this.getArchitectViewId());

    // pass SDK key if you have one, this one is only valid for this package identifier and must not be used somewhere else
    final ArchitectConfig config = new ArchitectConfig(this.getWikitudeSDKLicenseKey());

    try {
        // first mandatory life-cycle notification
        this.architectView.onCreate(config);
    } catch (RuntimeException rex) {
        this.architectView = null;
        Toast.makeText(getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT).show();
        Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
    }

    // set accuracy listener if implemented, you may e.g. show calibration prompt for compass using this listener
    this.sensorAccuracyListener = this.getSensorAccuracyListener();

    // set urlListener, any calls made in JS like "document.location = 'architectsdk://foo?bar=123'" is forwarded to this listener, use this to interact between JS and native Android activity/fragment
    this.urlListener = this.getUrlListener();

    // register valid urlListener in architectView, ensure this is set before content is loaded to not miss any event
    if (this.urlListener != null && this.architectView != null) {
        this.architectView.registerUrlListener(this.getUrlListener());
    }

    // listener passed over to locationProvider, any location update is handled here
    this.locationListener = new LocationListener() {

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onProviderDisabled(String provider) {
        }

        @Override
        public void onLocationChanged(final Location location) {
            // forward location updates fired by LocationProvider to architectView, you can set lat/lon from any location-strategy
            if (location != null) {
                Log.i("location", location.toString());
                // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project)
                AbstractArchitectActivity.this.lastKnownLocation = location;
                if (AbstractArchitectActivity.this.architectView != null) {
                    // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information)
                    if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) {
                        AbstractArchitectActivity.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(), location.getAltitude(), location.getAccuracy());
                    } else {
                        AbstractArchitectActivity.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(),
                                location.hasAccuracy() ? location.getAccuracy() : 1000);
                    }
                }
            }
        }
    };

    // locationProvider used to fetch user position
    this.locationProvider = new LocationProvider(this, this.locationListener);
}

From source file:com.wiret.arbrowser.AbstractArchitectCamActivity.java

/** Called when the activity is first created. */
@SuppressLint("NewApi")
@Override//  ww  w  . ja v  a 2  s  . co  m
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    /* pressing volume up/down should cause music volume changes */
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    this.setTitle(this.getActivityTitle());

    /*  
     *   this enables remote debugging of a WebView on Android 4.4+ when debugging = true in AndroidManifest.xml
     *   If you get a compile time error here, ensure to have SDK 19+ used in your ADT/Eclipse.
     *   You may even delete this block in case you don't need remote debugging or don't have an Android 4.4+ device in place.
     *   Details: https://developers.google.com/chrome-developer-tools/docs/remote-debugging
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    kmlFile = getIntent().getData();

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE,
                        android.Manifest.permission.CAMERA, android.Manifest.permission.ACCESS_FINE_LOCATION },
                101);
    } else {
        try {
            this.setContentView(this.getContentViewId());
            initArView();
        } catch (Exception rex) {
            this.architectView = null;
            AbstractArchitectCamActivity.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(AbstractArchitectCamActivity.this, "AR not supported by this device.",
                            Toast.LENGTH_LONG).show();
                }
            });
            Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
            finish();
        }
    }

}

From source file:com.emuneee.nctrafficcams.ui.activities.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    setActionBar();//from   ww w. ja v a2  s . c  o  m
    HttpUtils.initializeVerifiedHostnames(this);
    boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
    // configure Google Analytics
    GoogleAnalytics.getInstance(this).setDryRun(isDebuggable);
    GoogleAnalytics.getInstance(this).getLogger()
            .setLogLevel(isDebuggable ? LogLevel.VERBOSE : LogLevel.WARNING);
    // setup fragment
    mFragment = new CameraGalleryFragment();
    mFragment.setRetainInstance(true);
    String tag = CameraGalleryFragment.TAG;
    getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, mFragment, tag).commit();

    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    mDBHelper = new CameraDBHelper(this);
    mGetLatestCamerasTask = new GetLatestCameras(this, mDBHelper, new MainActivityFinishListener());
    if (!pref.getBoolean(Constants.PREF_EULA_ACCEPTED, false)) {
        showEula();
    } else {
        mGetLatestCamerasTask.execute();
    }
}

From source file:com.github.czy1121.update.app.utils.UpdateUtil.java

public static boolean isDebuggable(Context context) {
    try {/*from   w w  w. j  a v  a  2s . c  o  m*/
        return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (Exception e) {

    }
    return false;
}