Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DeviceUtils {
- public static String createUniqueResource(String resource) {
- String res = String.format("%s_%s", resource, getDeviceUuid());
- Timber.d("Resource %s", res);
- return res;
- }
- public static String getDeviceUuid() {
- String uuid = UserPrefUtils.getString(AssistantApp.getContext(), UserPrefUtils.KEY_DEVICE_ID, null);
- if (uuid != null) {
- return uuid;
- }
- uuid = UUID.randomUUID().toString();
- UserPrefUtils.putString(AssistantApp.getContext(), UserPrefUtils.KEY_DEVICE_ID, uuid);
- return uuid;
- }
- @SuppressLint("HardwareIds")
- public static String generateDeviceIdentifier() {
- String androidId = Settings.Secure.getString(
- AssistantApp.getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
- if (androidId == null || androidId.length() == 0){
- Timber.e("No ANDROID_ID! Generated a[32]");
- return new String(new char[32]).replace('\0', 'a');
- }
- StringBuilder androidIdBuilder = new StringBuilder(androidId);
- while (androidIdBuilder.length() < 32) androidIdBuilder.append(androidId);
- return androidIdBuilder.toString().substring(0, 32);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement