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:a14n.geolocationdemo.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    // Reload the Flutter Dart code when the activity receives an intent
    // from the "flutter refresh" command.
    // This feature should only be enabled during development.  Use the
    // debuggable flag as an indicator that we are in development mode.
    if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        if (Intent.ACTION_RUN.equals(intent.getAction())) {
            flutterView.runFromBundle(intent.getDataString(), intent.getStringExtra("snapshot"));
        }//from ww w .  j a  v a  2s .  c o m
    }
}

From source file:org.xwalk.extensions.iap.java

private void init(String base64EncodedPublicKey) {
    if (mInitialized)
        return;/*w  w  w . j  a v  a  2  s . c o m*/

    final boolean isDebug = (0 != (mExtensionContext.getActivity().getApplicationInfo().flags
            & ApplicationInfo.FLAG_DEBUGGABLE));

    mHelper = new IabHelper(mExtensionContext.getActivity(), base64EncodedPublicKey);
    mHelper.enableDebugLogging(isDebug);

    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                Log.e(TAG, "Problem setting up in-app billing: " + result);
                return;
            }

            // Have we been disposed of in the meantime? If so, quit.
            if (mHelper == null)
                return;

            mInitialized = true;
        }
    });
}

From source file:at.kropf.curriculumvitae.augmented.AbstractArchitectCamActivity.java

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

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

    /* set samples content view */
    this.setContentView(this.getContentViewId());

    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);
        }
    }

    /* 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 StartupConfiguration config = new StartupConfiguration(this.getWikitudeSDKLicenseKey(),
            this.getFeatures(), this.getCameraPosition());

    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());
    }

    if (hasGeo()) {
        // 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) {
                    // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project)
                    AbstractArchitectCamActivity.this.lastKnownLocaton = location;
                    if (AbstractArchitectCamActivity.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) {
                            AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(),
                                    location.getLongitude(), location.getAltitude(), location.getAccuracy());
                        } else {
                            AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(),
                                    location.getLongitude(),
                                    location.hasAccuracy() ? location.getAccuracy() : 1000);
                        }
                    }
                }
            }
        };

        // locationProvider used to fetch user position
        this.locationProvider = getLocationProvider(this.locationListener);
    } else {
        this.locationProvider = null;
        this.locationListener = null;
    }
}

From source file:com.example.traveljoin.wikitude.AbstractArchitectCamFragmentV4.java

@SuppressLint("NewApi")
@Override/*w w w  .  ja v a  2s  .c  o m*/
public void onActivityCreated(final Bundle bundle) {
    super.onActivityCreated(bundle);

    // set architectView, important for upcoming lifecycle calls
    this.architectView = (ArchitectView) this.getView().findViewById(getArchitectViewId());

    // pass license key to architectView while creating it
    final ArchitectConfig config = new ArchitectConfig(this.getWikitudeSDKLicenseKey());

    // forwards mandatory life-cycle-events, unfortunately there is no onPostCreate() event in fragments so we have to call it that way
    try {
        /* first mandatory life-cycle notification */
        this.architectView.onCreate(config);
        this.architectView.onPostCreate();
    } catch (RuntimeException rex) {
        this.architectView = null;
        Toast.makeText(getActivity().getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT)
                .show();
        Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
    }

    /*  
     *   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 != (getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    try {

        // load architectView's content
        this.architectView.load(this.getARchitectWorldPath());

        if (this.getInitialCullingDistanceMeters() != ArchitectViewHolderInterface.CULLING_DISTANCE_DEFAULT_METERS) {
            // set the culling distance - meaning: the maximum distance to render geo-content
            this.architectView.setCullingDistance(this.getInitialCullingDistanceMeters());
        }

    } catch (IOException e) {
        // unexpected, if error occurs here your path is invalid
        e.printStackTrace();
    }

    // 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) {
            if (location != null) {
                AbstractArchitectCamFragmentV4.this.lastKnownLocaton = location;
                if (AbstractArchitectCamFragmentV4.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) {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(), location.getAltitude(), location.getAccuracy());
                    } else {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(),
                                location.hasAccuracy() ? location.getAccuracy() : 1000);
                    }
                }
            }
        }
    };

    // 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.registerUrlListener(this.getUrlListener());
    }

    // locationProvider used to fetch user position
    this.locationProvider = this.getLocationProvider(this.locationListener);

}

From source file:com.pseudosudostudios.jdd.activities.WinActivity.java

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

From source file:at.ac.uniklu.mobile.sportal.Studentportal.java

/**
 * Tells if the application has been built in debug mode.
 * code taken and adapted from: http://stackoverflow.com/questions/3029819/android-automatically-choose-debug-release-maps-api-key
 * @param context//from   w ww .ja va  2  s . com
 * @return
 */
private static boolean isDebugBuild(Context context) {
    try {
        PackageManager pm = context.getPackageManager();
        PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
        return ((pi.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
    } catch (Exception e) {
    }
    return false;
}

From source file:com.spectralinsights.locar.AbstractArchitectCamFragmentV4.java

@SuppressLint("NewApi")
@Override//from   w  w  w. j a v a2s . c  o m
public void onActivityCreated(final Bundle bundle) {
    super.onActivityCreated(bundle);

    // set architectView, important for upcoming lifecycle calls
    this.architectView = (ArchitectView) this.getView().findViewById(getArchitectViewId());

    // pass license key to architectView while creating it
    final StartupConfiguration config = new StartupConfiguration(this.getWikitudeSDKLicenseKey(),
            ArchitectView.getSupportedFeaturesForDevice(getActivity()));

    // forwards mandatory life-cycle-events, unfortunately there is no onPostCreate() event in fragments so we have to call it that way
    try {
        /* first mandatory life-cycle notification */
        this.architectView.onCreate(config);
        this.architectView.onPostCreate();
    } catch (RuntimeException rex) {
        this.architectView = null;
        Toast.makeText(getActivity().getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT)
                .show();
        Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
    }

    /*  
     *   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 != (getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    try {

        // load architectView's content
        this.architectView.load(this.getARchitectWorldPath());

        if (this.getInitialCullingDistanceMeters() != ArchitectViewHolderInterface.CULLING_DISTANCE_DEFAULT_METERS) {
            // set the culling distance - meaning: the maximum distance to render geo-content
            this.architectView.setCullingDistance(this.getInitialCullingDistanceMeters());
        }

    } catch (IOException e) {
        // unexpected, if error occurs here your path is invalid
        e.printStackTrace();
    }

    // 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) {
            if (location != null) {
                AbstractArchitectCamFragmentV4.this.lastKnownLocaton = location;
                if (AbstractArchitectCamFragmentV4.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) {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(), location.getAltitude(), location.getAccuracy());
                    } else {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(),
                                location.hasAccuracy() ? location.getAccuracy() : 1000);
                    }
                }
            }
        }
    };

    // 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.registerUrlListener(this.getUrlListener());
    }

    // locationProvider used to fetch user position
    this.locationProvider = this.getLocationProvider(this.locationListener);

}

From source file:com.example.user.anniefyppostcard.fragments.AbstractArchitectCamFragmentV4.java

@SuppressLint("NewApi")
@Override//from  w  w  w. j  a v  a 2  s. c  o m
public void onActivityCreated(final Bundle bundle) {
    super.onActivityCreated(bundle);

    // set architectView, important for upcoming lifecycle calls
    this.architectView = (ArchitectView) this.getView().findViewById(getArchitectViewId());

    // pass license key to architectView while creating it
    final StartupConfiguration config = new StartupConfiguration(this.getWikitudeSDKLicenseKey(),
            ArchitectView.getSupportedFeaturesForDevice(getActivity()));

    // forwards mandatory life-cycle-events, unfortunately there is no onPostCreate() event in fragments so we have to call it that way
    try {
        /* first mandatory life-cycle notification */
        this.architectView.onCreate(config);
        this.architectView.onPostCreate();
    } catch (RuntimeException rex) {
        this.architectView = null;
        Toast.makeText(getActivity().getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT)
                .show();
        Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
    }

    /*
     *   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 != (getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    try {

        // load architectView's content
        this.architectView.load(this.getARchitectWorldPath());

        if (this.getInitialCullingDistanceMeters() != ArchitectViewHolderInterface.CULLING_DISTANCE_DEFAULT_METERS) {
            // set the culling distance - meaning: the maximum distance to render geo-content
            this.architectView.setCullingDistance(this.getInitialCullingDistanceMeters());
        }

    } catch (IOException e) {
        // unexpected, if error occurs here your path is invalid
        e.printStackTrace();
    }

    // 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) {
            if (location != null) {
                AbstractArchitectCamFragmentV4.this.lastKnownLocaton = location;
                if (AbstractArchitectCamFragmentV4.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) {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(), location.getAltitude(), location.getAccuracy());
                    } else {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(),
                                location.hasAccuracy() ? location.getAccuracy() : 1000);
                    }
                }
            }
        }
    };

    // 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.registerUrlListener(this.getUrlListener());
    }

    // locationProvider used to fetch user position
    this.locationProvider = this.getLocationProvider(this.locationListener);

}

From source file:com.wikitude.samples.AbstractArchitectCamFragmentV4.java

@SuppressLint("NewApi")
@Override//  w  w  w  . j  a v a2s  .  c  o  m
public void onActivityCreated(final Bundle bundle) {
    super.onActivityCreated(bundle);

    // set architectView, important for upcoming lifecycle calls
    this.architectView = (ArchitectView) this.getView().findViewById(getArchitectViewId());

    // pass license key to architectView while creating it
    final ArchitectStartupConfiguration config = new ArchitectStartupConfiguration();
    config.setLicenseKey(this.getWikitudeSDKLicenseKey());
    config.setFeatures(ArchitectView.getSupportedFeaturesForDevice(getActivity()));
    config.setCameraResolution(CameraSettings.CameraResolution.SD_640x480);

    // forwards mandatory life-cycle-events, unfortunately there is no onPostCreate() event in fragments so we have to call it that way
    try {
        /* first mandatory life-cycle notification */
        this.architectView.onCreate(config);
        this.architectView.onPostCreate();
    } catch (RuntimeException rex) {
        this.architectView = null;
        Toast.makeText(getActivity().getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT)
                .show();
        Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
    }

    /*  
     *   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 != (getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    try {

        // load architectView's content
        this.architectView.load(this.getARchitectWorldPath());

        if (this.getInitialCullingDistanceMeters() != ArchitectViewHolderInterface.CULLING_DISTANCE_DEFAULT_METERS) {
            // set the culling distance - meaning: the maximum distance to render geo-content
            this.architectView.setCullingDistance(this.getInitialCullingDistanceMeters());
        }

    } catch (IOException e) {
        // unexpected, if error occurs here your path is invalid
        e.printStackTrace();
    }

    // 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) {
            if (location != null) {
                AbstractArchitectCamFragmentV4.this.lastKnownLocaton = location;
                if (AbstractArchitectCamFragmentV4.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) {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(), location.getAltitude(), location.getAccuracy());
                    } else {
                        AbstractArchitectCamFragmentV4.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(),
                                location.hasAccuracy() ? location.getAccuracy() : 1000);
                    }
                }
            }
        }
    };

    // 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.registerUrlListener(this.getUrlListener());
    }

    // locationProvider used to fetch user position
    this.locationProvider = this.getLocationProvider(this.locationListener);

}

From source file:io.github.carlorodriguez.alarmon.AppSettings.java

public static boolean isDebugMode(Context c) {
    final String[] values = c.getResources().getStringArray(R.array.debug_values);
    final String DEBUG_DEFAULT = values[0];
    final String DEBUG_ON = values[1];
    final String DEBUG_OFF = values[2];

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
    final String value = prefs.getString(DEBUG_MODE, DEBUG_DEFAULT);
    if (value.equals(DEBUG_ON)) {
        return true;
    } else if (value.equals(DEBUG_OFF)) {
        return false;
    } else if (value.equals(DEBUG_DEFAULT)) {
        return (c.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0;
    } else {/*from w  w w .java2s  .co  m*/
        throw new IllegalStateException("Unknown debug mode setting: " + value);
    }
}