現在在庫管理システムを絶賛製作中だけど、機種によってUSBバーコードリーダの挙動がことなるから困ってしまう。GalaxyJのUsbManagerがnullを返す問題はSamsungにバグレポートを送るか悩み中。
バーコードリーダが接続されてるかのclassだけどこれでいいものだろうか
boolean USBexist=false;
boolean exist=false;
boolean returnExist=false;
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> map=manager.getDeviceList();
Iterator<UsbDevice> it = map.values().iterator();
while(it.hasNext()) {
UsbDevice device = it.next();
USBexist=true;
returnExist=true;
Log.d("USB", "NAME =" + device.getDeviceName());
// use device info
//if(showMessage)Toast.makeText(getApplicationContext(), "USBが接続されました。", Toast.LENGTH_SHORT).show();
}
if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
exist=true;
returnExist=true;
//if(showMessage)Toast.makeText(getApplicationContext(), "バーコードスキャナーが接続されました。", Toast.LENGTH_SHORT).show();
//((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker();
//Toast.makeText(this, "Barcode Scanner detected. Please turn OFF Hardware/Physical keyboard to enable softkeyboard to function.", Toast.LENGTH_LONG).show();
}

