TelephonyManager telmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String deviceID = telmgr.getDeviceId();
boolean isEmulator = "000000000000000".equalsIgnoreCase(deviceID);
if (isEmulator) {
((myApp) getApplication()).setBitmapX(BitmapFactory.decodeFile(imageFileName));
} else {
((myApp) getApplication()).setBitmapX(BitmapFactory.decodeByteArray((byte[]) args[0], 0, ((byte[])args[0]).length));
}
// TYPE_CLASS_NUMBER: Class for numeric text. This displays the numbers/symbols keyboard.
editText.setInputType(TYPE_CLASS_NUMBER);
// TYPE_CLASS_PHONE: Class for a phone number. This displays the phone number keypad.
editText.setInputType(TYPE_CLASS_PHONE);
1. 根据不同的形式修改button需要重写
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int w = <calculation>
int h = <calculation>
setMeasuredDimension(w, h);
}
2.
这里的随机数不仅仅是数字还可能是别的
final String alphabet = "0123456789ABCDE";
final int N = alphabet.length();
Random r = new Random();
for (int i = 0; i < 50; i++) {
System.out.print(alphabet.charAt(r.nextInt(N)));
}