Java Code Examples for android.os.Build#ID

The following examples show how to use android.os.Build#ID . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@NonNull
public String getUserAgent() {
    if (cachedUserAgent != null) {
        return cachedUserAgent;
    }

    String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName;
    String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName;
    Locale locale = Locale.getDefault();

    cachedUserAgent = packageName + "/" + versionName
            + " ChannelSDK/" + LINE_SDK_VERSION_FOR_TEST
            + " (Linux; U; Android " + Build.VERSION.RELEASE + "; "
            + locale.getLanguage() + "-" + locale.getCountry() + "; "
            + Build.MODEL
            + " Build/" + Build.ID + ")";
    return cachedUserAgent;
}
 
Example 2
@NonNull
public String getUserAgent() {
    if (cachedUserAgent != null) {
        return cachedUserAgent;
    }

    String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName;
    String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName;
    Locale locale = Locale.getDefault();

    cachedUserAgent = packageName + "/" + versionName
            + " ChannelSDK/" + sdkVersion
            + " (Linux; U; Android " + Build.VERSION.RELEASE + "; "
            + locale.getLanguage() + "-" + locale.getCountry() + "; "
            + Build.MODEL
            + " Build/" + Build.ID + ")";
    return cachedUserAgent;
}
 
Example 3
private static String getHandSetInfo() {
    String handSetInfo = "手机型号:" + Build.MODEL
            + "\n系统版本:" + Build.VERSION.RELEASE
            + "\n产品型号:" + Build.PRODUCT
            + "\n版本显示:" + Build.DISPLAY
            + "\n系统定制商:" + Build.BRAND
            + "\n设备参数:" + Build.DEVICE
            + "\n开发代号:" + Build.VERSION.CODENAME
            + "\nSDK版本号:" + Build.VERSION.SDK_INT
            + "\nCPU类型:" + Build.CPU_ABI
            + "\n硬件类型:" + Build.HARDWARE
            + "\n主机:" + Build.HOST
            + "\n生产ID:" + Build.ID
            + "\nROM制造商:" + Build.MANUFACTURER // 这行返回的是rom定制商的名称
            ;
    Log.e("tt",handSetInfo);
    return handSetInfo;
}
 
Example 4
public String getUserAgentString() {
    return "Android-Finsky/" + URLEncoder.encode(gsfVersionProvider.getVendingVersionString(true)).replace("+", "%20") + " ("
        + "api=3"
        + ",versionCode=" + gsfVersionProvider.getVendingVersionCode(true)
        + ",sdk=" + Build.VERSION.SDK_INT
        + ",device=" + Build.DEVICE
        + ",hardware=" + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO ? Build.HARDWARE : Build.PRODUCT)
        + ",product=" + Build.PRODUCT
        + ",platformVersionRelease=" + Build.VERSION.RELEASE
        + ",model=" + URLEncoder.encode(Build.MODEL).replace("+", "%20")
        + ",buildId=" + Build.ID
        + ",isWideScreen=" + (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? "1" : "0")
        + ",supportedAbis=" + TextUtils.join(";", getPlatforms())
        + ")"
    ;
}
 
Example 5
Source Project: libcommon   File: BluetoothManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * コンストラクタ
 * @param context
 * @param name サービス名, 任意, nullまたは空文字列ならば端末のモデルとIDを使う
 * @param secureProfileUUID 接続に使用するプロトコル(プロファイル)を識別するためのUUID。セキュア接続用。Android同士でつなぐなら任意で可。PC等のBluetoothシリアル通信を行うならUUID_SPPを使う
 * @param inSecureProfileUUID 接続に使用するプロトコル(プロファイル)を識別するためのUUID。インセキュア接続用。Android同士でつなぐなら任意で可。PC等のBluetoothシリアル通信を行うならUUID_SPPを使う nullならsecureProfileUUIDを使う
 * @param callback
 */
public BluetoothManager(@NonNull final Context context, final String name,
	@NonNull final UUID secureProfileUUID,
	@Nullable final UUID inSecureProfileUUID,
	@NonNull final BluetoothManagerCallback callback) {

	mWeakContext = new WeakReference<Context>(context);
	mName = !TextUtils.isEmpty(name) ? name : Build.MODEL + "_" + Build.ID;
	mSecureProfileUUID = secureProfileUUID;
	mInSecureProfileUUID = inSecureProfileUUID != null ? inSecureProfileUUID : secureProfileUUID;
	if (callback != null) {
		mCallbacks.add(callback);
	}
	mAdapter = BluetoothAdapter.getDefaultAdapter();
	if ((mAdapter == null) || !mAdapter.isEnabled()) {
		throw new IllegalStateException("bluetoothに対応していないか無効になっている");
	}
	mState = STATE_NONE;
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
	filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
	context.registerReceiver(mBroadcastReceiver, filter);
}
 
Example 6
private void recordInformations(Context context) {
	try {
		PackageManager pm = context.getPackageManager();
		PackageInfo pi;
		// Version
		pi = pm.getPackageInfo(context.getPackageName(), 0);
		versionName = pi.versionName;
		//buildNumber = currentVersionNumber(context);
		// Package name
		packageName = pi.packageName;

		// Device model
		phoneModel = Build.MODEL;
		// Android version
		androidVersion = Build.VERSION.RELEASE;

		board = Build.BOARD;
		brand = Build.BRAND;
		device = Build.DEVICE;
		display = Build.DISPLAY;
		fingerPrint = Build.FINGERPRINT;
		host = Build.HOST;
		id = Build.ID;
		model = Build.MODEL;
		product = Build.PRODUCT;
		manufacturer = Build.MANUFACTURER;
		tags = Build.TAGS;
		time = Build.TIME;
		type = Build.TYPE;
		user = Build.USER;

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 7
/**
 * 获取系统UA值
 *
 * @return
 */
public static String getDefaultUserAgent() {
    String result = System.getProperty("http.agent");
    if (!TextUtils.isEmpty(result)) {
        result = "("+ System.getProperty("os.name")+"/Android "  + Build.VERSION.RELEASE + "/" +
                Build.MODEL+"/"+ Build.ID+")";
    }
    return result.replaceAll("[^\\p{ASCII}]", "?");
}
 
Example 8
public static AndroidModel forThisDevice() {
    return new AndroidModel(
        Build.VERSION.RELEASE,
        Build.ID,
        Build.MODEL,
        Build.MANUFACTURER);
}
 
Example 9
@CalledByNative
private static String[] getAll() {
    BuildInfo buildInfo = getInstance();
    String hostPackageName = ContextUtils.getApplicationContext().getPackageName();
    return new String[] {
            Build.BRAND, Build.DEVICE, Build.ID, Build.MANUFACTURER, Build.MODEL,
            String.valueOf(Build.VERSION.SDK_INT), Build.TYPE, Build.BOARD, hostPackageName,
            String.valueOf(buildInfo.hostVersionCode), buildInfo.hostPackageLabel,
            buildInfo.packageName, String.valueOf(buildInfo.versionCode), buildInfo.versionName,
            buildInfo.androidBuildFingerprint, buildInfo.gmsVersionCode,
            buildInfo.installerPackageName, buildInfo.abiString, BuildConfig.FIREBASE_APP_ID,
            buildInfo.customThemes, buildInfo.resourcesVersion, buildInfo.extractedFileSuffix,
    };
}
 
Example 10
Source Project: CrashReporter   File: AppUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String getDeviceDetails(Context context) {

        return "Device Information\n"
                + "\nDEVICE.ID : " + getDeviceId(context)
                + "\nUSER.ID : " + getUserIdentity(context)
                + "\nAPP.VERSION : " + getAppVersion(context)
                + "\nLAUNCHER.APP : " + getCurrentLauncherApp(context)
                + "\nTIMEZONE : " + timeZone()
                + "\nVERSION.RELEASE : " + Build.VERSION.RELEASE
                + "\nVERSION.INCREMENTAL : " + Build.VERSION.INCREMENTAL
                + "\nVERSION.SDK.NUMBER : " + Build.VERSION.SDK_INT
                + "\nBOARD : " + Build.BOARD
                + "\nBOOTLOADER : " + Build.BOOTLOADER
                + "\nBRAND : " + Build.BRAND
                + "\nCPU_ABI : " + Build.CPU_ABI
                + "\nCPU_ABI2 : " + Build.CPU_ABI2
                + "\nDISPLAY : " + Build.DISPLAY
                + "\nFINGERPRINT : " + Build.FINGERPRINT
                + "\nHARDWARE : " + Build.HARDWARE
                + "\nHOST : " + Build.HOST
                + "\nID : " + Build.ID
                + "\nMANUFACTURER : " + Build.MANUFACTURER
                + "\nMODEL : " + Build.MODEL
                + "\nPRODUCT : " + Build.PRODUCT
                + "\nSERIAL : " + Build.SERIAL
                + "\nTAGS : " + Build.TAGS
                + "\nTIME : " + Build.TIME
                + "\nTYPE : " + Build.TYPE
                + "\nUNKNOWN : " + Build.UNKNOWN
                + "\nUSER : " + Build.USER;
    }
 
Example 11
Source Project: android   File: HeaderInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
private String getDefaultUserAgent(String cversion) {
    StringBuilder result = new StringBuilder(64);

    if (cversion != null) {
        result.append("MalaysiaPrayerTimes/");
        result.append(cversion);
    } else {
        result.append("Dalvik/");
        result.append(System.getProperty("java.vm.version")); // such as 1.1.0
    }

    result.append(" (Linux; U; Android ");

    String version = Build.VERSION.RELEASE; // "1.0" or "3.4b5"
    result.append(version.length() > 0 ? version : "1.0");

    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        String model = Build.MODEL;
        if (model.length() > 0) {
            result.append("; ");
            result.append(model);
        }
    }
    String id = Build.ID; // "MASTER" or "M4-rc20"
    if (id.length() > 0) {
        result.append(" Build/");
        result.append(id);
    }
    result.append(")");
    return result.toString();
}
 
Example 12
@CalledByNative
public static String getAndroidBuildId() {
    return Build.ID;
}
 
Example 13
Source Project: DoraemonKit   File: HttpHeaders.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * User-Agent: Mozilla/5.0 (Linux; U; Android 5.0.2; zh-cn; Redmi Note 3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
 */
public static String getUserAgent() {
    if (TextUtils.isEmpty(userAgent)) {
        String webUserAgent = null;
        try {
            Class<?> sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = DokitOkGo.getInstance().getContext().getString(resId);
        } catch (Exception e) {
            // We have nothing to do
        }
        if (TextUtils.isEmpty(webUserAgent)) {
            webUserAgent = "okhttp-okgo/jeasonlzy";
        }

        Locale locale = Locale.getDefault();
        StringBuffer buffer = new StringBuffer();
        // Add version
        final String version = Build.VERSION.RELEASE;
        if (version.length() > 0) {
            buffer.append(version);
        } else {
            // default to "1.0"
            buffer.append("1.0");
        }
        buffer.append("; ");
        final String language = locale.getLanguage();
        if (language != null) {
            buffer.append(language.toLowerCase(locale));
            final String country = locale.getCountry();
            if (!TextUtils.isEmpty(country)) {
                buffer.append("-");
                buffer.append(country.toLowerCase(locale));
            }
        } else {
            // default to "en"
            buffer.append("en");
        }
        // add the model for the release build
        if ("REL".equals(Build.VERSION.CODENAME)) {
            final String model = Build.MODEL;
            if (model.length() > 0) {
                buffer.append("; ");
                buffer.append(model);
            }
        }
        final String id = Build.ID;
        if (id.length() > 0) {
            buffer.append(" Build/");
            buffer.append(id);
        }
        userAgent = String.format(webUserAgent, buffer, "Mobile ");
        return userAgent;
    }
    return userAgent;
}
 
Example 14
Source Project: DoraemonKit   File: HttpHeaders.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * User-Agent: Mozilla/5.0 (Linux; U; Android 5.0.2; zh-cn; Redmi Note 3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
 */
public static String getUserAgent() {
    if (TextUtils.isEmpty(userAgent)) {
        String webUserAgent = null;
        try {
            Class<?> sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = DokitOkGo.getInstance().getContext().getString(resId);
        } catch (Exception e) {
            // We have nothing to do
        }
        if (TextUtils.isEmpty(webUserAgent)) {
            webUserAgent = "okhttp-okgo/jeasonlzy";
        }

        Locale locale = Locale.getDefault();
        StringBuffer buffer = new StringBuffer();
        // Add version
        final String version = Build.VERSION.RELEASE;
        if (version.length() > 0) {
            buffer.append(version);
        } else {
            // default to "1.0"
            buffer.append("1.0");
        }
        buffer.append("; ");
        final String language = locale.getLanguage();
        if (language != null) {
            buffer.append(language.toLowerCase(locale));
            final String country = locale.getCountry();
            if (!TextUtils.isEmpty(country)) {
                buffer.append("-");
                buffer.append(country.toLowerCase(locale));
            }
        } else {
            // default to "en"
            buffer.append("en");
        }
        // add the model for the release build
        if ("REL".equals(Build.VERSION.CODENAME)) {
            final String model = Build.MODEL;
            if (model.length() > 0) {
                buffer.append("; ");
                buffer.append(model);
            }
        }
        final String id = Build.ID;
        if (id.length() > 0) {
            buffer.append(" Build/");
            buffer.append(id);
        }
        userAgent = String.format(webUserAgent, buffer, "Mobile ");
        return userAgent;
    }
    return userAgent;
}
 
Example 15
public String getBuildId() {
    return Build.ID;
}
 
Example 16
Source Project: unity-ads-android   File: Device.java    License: Apache License 2.0 4 votes vote down vote up
public static String getBuildId() {
	return Build.ID;
}
 
Example 17
/**
 * @param context if null, use the default format
 *                (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30).
 * @return
 */
public static String getUserAgent(Context context) {
    String webUserAgent = null;
    if (context != null) {
        try {
            Class sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = context.getString(resId);
        } catch (Throwable ignored) {
        }
    }
    if (TextUtils.isEmpty(webUserAgent)) {
        webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1";
    }

    Locale locale = Locale.getDefault();
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        buffer.append(version);
    } else {
        // default to "1.0"
        buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
        buffer.append(language.toLowerCase());
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase());
        }
    } else {
        // default to "en"
        buffer.append("en");
    }
    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        final String model = Build.MODEL;
        if (model.length() > 0) {
            buffer.append("; ");
            buffer.append(model);
        }
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        buffer.append(" Build/");
        buffer.append(id);
    }
    return String.format(webUserAgent, buffer, "Mobile ");
}
 
Example 18
Source Project: RxEasyHttp   File: HttpHeaders.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * User-Agent: Mozilla/5.0 (Linux; U; Android 5.0.2; zh-cn; Redmi Note 3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
 */
public static String getUserAgent() {
    if (TextUtils.isEmpty(userAgent)) {
        String webUserAgent = null;
        try {
            Class<?> sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = EasyHttp.getContext().getString(resId);
        } catch (Exception e) {
            // We have nothing to do
        }
        if (TextUtils.isEmpty(webUserAgent)) {
            webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/5.0 %sSafari/533.1";
        }

        Locale locale = Locale.getDefault();
        StringBuffer buffer = new StringBuffer();
        // Add version
        final String version = Build.VERSION.RELEASE;
        if (version.length() > 0) {
            buffer.append(version);
        } else {
            // default to "1.0"
            buffer.append("1.0");
        }
        buffer.append("; ");
        final String language = locale.getLanguage();
        if (language != null) {
            buffer.append(language.toLowerCase(locale));
            final String country = locale.getCountry();
            if (!TextUtils.isEmpty(country)) {
                buffer.append("-");
                buffer.append(country.toLowerCase(locale));
            }
        } else {
            // default to "en"
            buffer.append("en");
        }
        // add the model for the release build
        if ("REL".equals(Build.VERSION.CODENAME)) {
            final String model = Build.MODEL;
            if (model.length() > 0) {
                buffer.append("; ");
                buffer.append(model);
            }
        }
        final String id = Build.ID;
        if (id.length() > 0) {
            buffer.append(" Build/");
            buffer.append(id);
        }
        userAgent = String.format(webUserAgent, buffer, "Mobile ");
        return userAgent;
    }
    return userAgent;
}
 
Example 19
/**
 * @param context if null, use the default format
 *                (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30).
 * @return
 */
public static String getUserAgent(Context context) {
    String webUserAgent = null;
    if (context != null) {
        try {
            Class sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = context.getString(resId);
        } catch (Throwable ignored) {
        }
    }
    if (TextUtils.isEmpty(webUserAgent)) {
        webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1";
    }

    Locale locale = Locale.getDefault();
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        buffer.append(version);
    } else {
        // default to "1.0"
        buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
        buffer.append(language.toLowerCase());
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase());
        }
    } else {
        // default to "en"
        buffer.append("en");
    }
    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        final String model = Build.MODEL;
        if (model.length() > 0) {
            buffer.append("; ");
            buffer.append(model);
        }
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        buffer.append(" Build/");
        buffer.append(id);
    }
    return String.format(webUserAgent, buffer, "Mobile ");
}
 
Example 20
Source Project: SimpleProject   File: DeviceUtil.java    License: MIT License 2 votes vote down vote up
/**
 * 获取设备AndroidId
 * @return
 */
public static String getAndroidId() {
	return Build.ID;
}