本文整理汇总了Java中android.provider.Settings.Secure.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Secure.getString方法的具体用法?Java Secure.getString怎么用?Java Secure.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.provider.Settings.Secure
的用法示例。
在下文中一共展示了Secure.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: c
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static synchronized String c(Context context) {
String str;
synchronized (f.class) {
if (c != null) {
str = c;
} else {
String string;
try {
string = Secure.getString(context.getContentResolver(), "android_id");
} catch (Throwable th) {
b.a(th);
string = null;
}
c = d.b(string + (VERSION.SDK_INT > 8 ? Build.SERIAL : null));
str = c;
}
}
return str;
}
示例2: if
import android.provider.Settings.Secure; //导入方法依赖的package包/类
private void b04390439й043904390439() {
try {
ContentResolver contentResolver = this.bььь044Cьь.getContentResolver();
if (((b041EО041EО041EО() + b041E041EОО041EО) * b041EО041EО041EО()) % bОО041EО041EО != bО041EОО041EО) {
b041EООО041EО = b041EО041EО041EО();
bО041EОО041EО = b041EО041EО041EО();
}
try {
this.bьь044Cььь = Secure.getString(contentResolver, "android_id");
} catch (Exception e) {
throw e;
}
} catch (Exception e2) {
throw e2;
}
}
示例3: getEnabledListenerPackages
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static Set<String> getEnabledListenerPackages(Context context) {
String enabledNotificationListeners = Secure.getString(context.getContentResolver(), SETTING_ENABLED_NOTIFICATION_LISTENERS);
if (!(enabledNotificationListeners == null || enabledNotificationListeners.equals(sEnabledNotificationListeners))) {
String[] components = enabledNotificationListeners.split(NetworkUtils.DELIMITER_COLON);
Set<String> packageNames = new HashSet(components.length);
for (String component : components) {
ComponentName componentName = ComponentName.unflattenFromString(component);
if (componentName != null) {
packageNames.add(componentName.getPackageName());
}
}
synchronized (sEnabledNotificationListenersLock) {
sEnabledNotificationListenerPackages = packageNames;
sEnabledNotificationListeners = enabledNotificationListeners;
}
}
return sEnabledNotificationListenerPackages;
}
示例4: getDeviceId
import android.provider.Settings.Secure; //导入方法依赖的package包/类
/**
* 获取deviceId
*
* @param mContext
* @return
*/
public static String getDeviceId(Context mContext)
{
String deviceId = getIMEI(mContext);
if (deviceId == null || deviceId.equals(""))
{
deviceId = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID);
if (deviceId == null || deviceId.equals("") || deviceId.equals("9774d56d682e549c"))
{
deviceId = "";
}
}
return deviceId;
}
示例5: getDeviceId
import android.provider.Settings.Secure; //导入方法依赖的package包/类
/**
* 获取手机的设备号或wifi的mac号
*
* @param context 上下文
* @return 在wifi环境下只返回mac地址,否则返回手机设备号, 在模拟器情况下会返回null
*/
public static String getDeviceId(Context context) {
WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = manager.getConnectionInfo();
String macAddress = wifiInfo.getMacAddress();
if (null != macAddress) {
// Log.d(Thread.currentThread().getName(), "mac:" + macAddress);
return macAddress.replace(".", "").replace(":", "").replace("-", "").replace("_", "").replace("+", "").replace("-", "").replace("=", "");
} else {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String imei = tm.getDeviceId();
if (null != imei && !SPECIAL_IMEI.equals(imei)) {
// Log.d(Thread.currentThread().getName(), "imei:" + imei);
return imei;
} else {
String deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
if (null != deviceId) {
// Log.d(Thread.currentThread().getName(), "ANDROID_ID:" + deviceId);
return deviceId.replace("+", "").replace("-", "").replace("=", "");
}
return null;
}
}
}
示例6: registerHash
import android.provider.Settings.Secure; //导入方法依赖的package包/类
/**
* Register hash for the device helper function.
*/
private void registerHash() {
String hash = Secure.getString(this.getContentResolver(),
Secure.ANDROID_ID);
if (hash == null || hash == "") {
hash = Long
.toHexString(UUID.randomUUID().getLeastSignificantBits());
}
SharedPreferences preference = PreferenceManager
.getDefaultSharedPreferences(this);
String stored = preference.getString(
Util.SHARED_PREFERENCE_INSTNCE_HASH_CODE_KEY, "");
/*
* Write only once in the first start of the application.
*/
if (stored.equals("") == true) {
SharedPreferences.Editor editor = preference.edit();
editor.putString(Util.SHARED_PREFERENCE_INSTNCE_HASH_CODE_KEY, hash);
editor.commit();
}
}
示例7: getDeviceId
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static String getDeviceId(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return "0_0";
}
StringBuffer sb = new StringBuffer();
String imei = tm.getDeviceId();
sb.append(TextUtils.isEmpty(imei) ? "0" : imei);
sb.append("_");
String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
sb.append(TextUtils.isEmpty(androidId) ? "0" : androidId);
return sb.toString();
}
示例8: getDeviceId
import android.provider.Settings.Secure; //导入方法依赖的package包/类
/**
* 获取手机的设备号或wifi的mac号
*
* @param context 上下文
* @return 在wifi环境下只返回mac地址,否则返回手机设备号, 在模拟器情况下会返回null
*/
public static String getDeviceId(Context context) {
WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = manager.getConnectionInfo();
String macAddress = wifiInfo.getMacAddress();
if (null != macAddress) {
return macAddress.replace(".", "").replace(":", "").replace("-", "").replace("_", "").replace("+", "").replace("-", "").replace("=", "");
} else {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String imei = tm.getDeviceId();
if (StringUtil.isNotBlank(imei) && !SPECIAL_IMEI.equals(imei)) {
return imei;
} else {
String deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
if (null != deviceId) {
return deviceId.replace("+", "").replace("-", "").replace("=", "");
}
return null;
}
}
}
示例9: getIMEI
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static String getIMEI() {
String imei = "";
try{
Context ctx = ExApplication.getContext();
TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
imei = telephonyManager.getDeviceId();
if (TextUtils.isEmpty(imei))
imei = Secure.getString(ctx.getContentResolver(), Secure.ANDROID_ID);
if(imei == null)
imei = "";
}
}catch(Exception e){
if(LogMgr.isDebug())
e.printStackTrace();
}
return imei;
}
示例10: isEnableAutoInstall
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static boolean isEnableAutoInstall() {
Context mContext = AutoInstallerContext.getContext();
SimpleStringSplitter simpleStringSplitter = new SimpleStringSplitter(':');
if (!SettingsUtil.isAccessibiltiyEnable(mContext)) {
return false;
}
String string = Secure.getString(mContext.getContentResolver(), "enabled_accessibility_services");
if (string == null) {
return false;
}
simpleStringSplitter.setString(string);
while (simpleStringSplitter.hasNext()) {
if (simpleStringSplitter.next().equalsIgnoreCase(
AutoInstallerContext.getTargetService())) {
return true;
}
}
return false;
}
示例11: isLocationEnabled
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static boolean isLocationEnabled(Context context) {
int locationMode = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
locationMode = Secure.getInt(context.getContentResolver(), Secure.LOCATION_MODE);
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
return locationMode != Secure.LOCATION_MODE_OFF;
} else {
String locationProviders = Secure.getString(context.getContentResolver(),
Secure.LOCATION_PROVIDERS_ALLOWED);
return !locationProviders.isEmpty();
}
}
示例12: generateID
import android.provider.Settings.Secure; //导入方法依赖的package包/类
private static String generateID(Context context) {
// use the ANDROID_ID constant, generated at the first device boot
String deviceId = Secure.getString(context.getContentResolver(),
Secure.ANDROID_ID);
// in case known problems are occured
if (deviceId == null) {
// get a unique deviceID like IMEI for GSM or ESN for CDMA phones
// don't forget:
// <uses-permission
// android:name="android.permission.READ_PHONE_STATE" />
deviceId = ((TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
// if nothing else works, generate a random number
if (deviceId == null) {
Random tmpRand = new Random();
deviceId = String.valueOf(tmpRand.nextLong());
}
}
// any value is hashed to have consistent format
return getHash(deviceId);
}
示例13: getSimpleDeviceId
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static String getSimpleDeviceId(Context context) {
TelephonyManager tManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String result = tManager.getDeviceId();
if (!TextUtils.isEmpty(result)) {
return result;
}
try {
result = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
} catch (Exception e) {
Log.e(tag, "Secure error.", e);
}
if (!TextUtils.isEmpty(result)) {
return result;
}
result = UUID.randomUUID().toString();
return result;
}
示例14: generateOpenUDID
import android.provider.Settings.Secure; //导入方法依赖的package包/类
private void generateOpenUDID() {
if (LOG) Log.d(TAG, "Generating openUDID");
//Try to get the ANDROID_ID
OpenUDID = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID);
if (OpenUDID == null || OpenUDID.equals("9774d56d682e549c") || OpenUDID.length() < 15 ) {
//if ANDROID_ID is null, or it's equals to the GalaxyTab generic ANDROID_ID or bad, generates a new one
final SecureRandom random = new SecureRandom();
OpenUDID = new BigInteger(64, random).toString(16);
}
}
示例15: getHashedDeviceAndAppID
import android.provider.Settings.Secure; //导入方法依赖的package包/类
public static String getHashedDeviceAndAppID(Context context, String applicationId) {
String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
if (androidId == null) {
return null;
} else {
return sha1hash(androidId + applicationId);
}
}