android.os.Build#ID源码实例Demo

下面列出了android.os.Build#ID 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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;
}
 
源代码2 项目: line-sdk-android   文件: UserAgentGenerator.java
@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;
}
 
源代码3 项目: MainActivityUIUtil   文件: StatusbarUtil.java
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;
}
 
源代码4 项目: YalpStore   文件: NativeDeviceInfoProvider.java
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())
        + ")"
    ;
}
 
源代码5 项目: libcommon   文件: BluetoothManager.java
/**
 * コンストラクタ
 * @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);
}
 
源代码6 项目: aliyun-log-android-sdk   文件: VersionInfoUtils.java
/**
 * 获取系统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}]", "?");
}
 
源代码7 项目: android-beacon-library   文件: AndroidModel.java
public static AndroidModel forThisDevice() {
    return new AndroidModel(
        Build.VERSION.RELEASE,
        Build.ID,
        Build.MODEL,
        Build.MANUFACTURER);
}
 
源代码8 项目: cronet   文件: BuildInfo.java
@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,
    };
}
 
源代码9 项目: CrashReporter   文件: AppUtils.java
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;
    }
 
源代码10 项目: AutoCrashReporter   文件: AutoErrorReporter.java
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();
	}
}
 
源代码11 项目: android   文件: HeaderInterceptor.java
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();
}
 
源代码12 项目: android-chromium   文件: BuildInfo.java
@CalledByNative
public static String getAndroidBuildId() {
    return Build.ID;
}
 
源代码13 项目: DoraemonKit   文件: HttpHeaders.java
/**
 * 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;
}
 
源代码14 项目: DoraemonKit   文件: HttpHeaders.java
/**
 * 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;
}
 
源代码15 项目: matomo-sdk-android   文件: BuildInfo.java
public String getBuildId() {
    return Build.ID;
}
 
源代码16 项目: unity-ads-android   文件: Device.java
public static String getBuildId() {
	return Build.ID;
}
 
源代码17 项目: BigApp_Discuz_Android   文件: OtherUtils.java
/**
 * @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 ");
}
 
源代码18 项目: RxEasyHttp   文件: HttpHeaders.java
/**
 * 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;
}
 
源代码19 项目: android-open-project-demo   文件: OtherUtils.java
/**
 * @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 ");
}
 
源代码20 项目: SimpleProject   文件: DeviceUtil.java
/**
 * 获取设备AndroidId
 * @return
 */
public static String getAndroidId() {
	return Build.ID;
}