/** * This function clears the Command Display and the command history. * * @param v - the view of the widget calling this function */ public void resetDisplay(View v) { RoboCatActivity.clearGaitButton(); HWSectionFragment.updateOutput(); // Examples of audio playback in different section of the app // -----From a static context---- // String [] aud = getResources().getStringArray(R.array.audio_files); // try{ // AudioChooser.Play_audio(v.getContext(),"Scream",aud); // } // catch (FileNotFoundException f){ // // } // -----From a non-static context---- // AudioChooser.Play_audio(v.getContext(),"Scream"); }
@Override /** * This function checks for which intent started the app and checks whether a usb device is * attached or not */ public void onResume() { super.onResume(); Intent intent = getIntent(); Log.d(TAG, "onResume(" + intent + ")"); String action = intent.getAction(); deviceConnected(false); if (action.equals("android.intent.action.MAIN")) { // Toast.makeText(getApplicationContext(), // "Reconnect the USB devices.", Toast.LENGTH_LONG).show(); // finish(); } if (action.equals("android.hardware.usb.action.USB_DEVICE_ATTACHED") | action.equals("android.intent.action.MAIN")) { UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) { Log.d(TAG, "INTENT DEVICE ATTACHED=" + device.toString()); RoboCatActivity.device = device; deviceConnected(true); } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) { Log.d(TAG, "INTENT DEVICE DETACHED=" + device.toString()); RoboCatActivity.device = device; deviceConnected(false); } else { Log.d(TAG, "Unexpected Action=" + action.toString()); } } else { // Toast.makeText(getApplicationContext(), // "Invalid USB device or USB device not found.", Toast.LENGTH_LONG).show(); } Log.d("About to initialize", "Initializing " + RoboCatActivity.deviceConnected); RoboCatActivity.initializeMaestro((UsbManager) getSystemService(USB_SERVICE)); }