本文整理汇总了Java中com.android.sdklib.devices.Device.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Device.getId方法的具体用法?Java Device.getId怎么用?Java Device.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.sdklib.devices.Device
的用法示例。
在下文中一共展示了Device.getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultDevice
import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
@Nullable
public Device getDefaultDevice() {
if (myDefaultDevice == null) {
// Note that this may not be the device actually used in new layouts; the ConfigMatcher
// has a PhoneComparator which sorts devices for a best match
List<Device> devices = getDevices();
if (!devices.isEmpty()) {
Device device = devices.get(0);
for (Device d : devices) {
String name = d.getId();
if (name.equals("Nexus 4")) {
device = d;
break;
} else if (name.equals("Galaxy Nexus")) {
device = d;
}
}
myDefaultDevice = device;
}
}
return myDefaultDevice;
}
示例2: createDevices
import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
/**
* Create the given devices
*/
public void createDevices(@NotNull List<Device> devices) {
if (!initIfNecessary()) {
return;
}
for (Device device : devices) {
// Find a unique ID for this new device
String deviceIdBase = device.getId();
String deviceNameBase = device.getDisplayName();
int i = 2;
while (isUserDevice(device)) {
String id = String.format(Locale.getDefault(), "%1$s_%2$d", deviceIdBase, i);
String name = String.format(Locale.getDefault(), "%1$s_%2$d", deviceNameBase, i);
device = cloneDeviceWithNewIdAndName(device, id, name);
}
ourDeviceManager.addUserDevice(device);
}
ourDeviceManager.saveUserDevices();
}
示例3: nexusRank
import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
/**
* Returns the rank of the given nexus device. This can be used to order
* the devices chronologically.
*
* @param device the device to look up the rank for
* @return the rank of the device
*/
public static int nexusRank(Device device) {
String id = device.getId();
if (id.equals("Nexus One")) { //$NON-NLS-1$
return 1;
}
if (id.equals("Nexus S")) { //$NON-NLS-1$
return 2;
}
if (id.equals("Galaxy Nexus")) { //$NON-NLS-1$
return 3;
}
if (id.equals("Nexus 7")) { //$NON-NLS-1$
return 4; // 2012 version
}
if (id.equals("Nexus 10")) { //$NON-NLS-1$
return 5;
}
if (id.equals("Nexus 4")) { //$NON-NLS-1$
return 6;
}
if (id.equals("Nexus 7 2013")) { //$NON-NLS-1$
return 7;
}
if (id.equals("Nexus 5")) { //$NON-NLS-1$
return 8;
}
if (id.equals("Nexus 9")) { //$NON-NLS-1$
return 9;
}
if (id.equals("Nexus 6")) { //$NON-NLS-1$
return 10;
}
return 100; // devices released in the future?
}
示例4: selectDevice
import com.android.sdklib.devices.Device; //导入方法依赖的package包/类
public void selectDevice(@NotNull Device device) {
// Manually move the given device to the front of the eligibility queue
String id = device.getId();
List<String> deviceIds = getStateManager().getProjectState().getDeviceIds();
deviceIds.remove(id);
deviceIds.add(0, id);
// Only store a limited number of recent devices
while (deviceIds.size() > 10) {
deviceIds.remove(deviceIds.size() - 1);
}
myStateVersion++;
for (Configuration configuration : myCache.values()) {
// TODO: Null out the themes too if using a system theme (e.g. where the theme was not chosen
// by the activity or manifest default, but inferred based on the device and API level).
// For example, if you switch from an Android Wear device (where the default is DeviceDefault) to
// a Nexus 5 (where the default is currently Theme.Holo) we should recompute the theme for the
// configuration too!
boolean updateTheme = false;
String theme = configuration.getTheme();
if (theme != null && theme.startsWith(ANDROID_STYLE_RESOURCE_PREFIX)) {
updateTheme = true;
configuration.startBulkEditing();
configuration.setTheme(null);
}
configuration.updated(CFG_DEVICE);
if (updateTheme) {
configuration.finishBulkEditing();
}
}
}