Eugene_Kr
Eugene_Kr

Reputation: 129

Nativescript. check for android settings enabled

Could anybody help to check for android settings enabled. Particularly how to check for DEVELOPMENT_SETTINGS_ENABLED???

Trying to do smth like this:

Settings.Secure.getInt(this.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0);

but can't get it...

or smt like this:

android.provider.Settings.Global.getInt(android.content.ContentResolver(), android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);

Upvotes: 0

Views: 156

Answers (1)

Nick Iliev
Nick Iliev

Reputation: 9670

Try the following:

import * as appModule from "tns-core-modules/application";
declare let android: any; // or better use tns-platform-declarations

const nativeApp = appModule.android.nativeApp;

let settings = android.provider.Settings.Secure.getInt(
    nativeApp.getContentResolver(),
    android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
    0
);

console.log(`settings ${settings}`);

Upvotes: 1

Related Questions