10.07.2015 Views

dissertation

dissertation

dissertation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}∗ Like addLogMessage ( S t r i n g ) , but c a l l a b l e from∗ o t h e r t h r e a d s .∗∗ @param s t r i n g∗ The l o g message .∗∗/public void addLogMessageFromOtherThread (f i n a l S t r i n g s t r i n g ) {// h t t p :// s t a c k o v e r f l o w . com/ q u e s t i o n s /3050937/// java−thread−message−p a s s i n grunOnUiThread (new Runnable ( ) {public void run ( ) {addLogMessage ( s t r i n g ) ;}} ) ;}C.1.5USBBroadcastReceiver.javapackage uk . ac . g l a . a r t s . h a t i i . usbmonitor ;import android . content . B roadcastReceiver ;import android . content . Context ;import android . content . I n t e n t ;import android . hardware . usb . UsbManager ;import android . os . Bundle ;public class USBBroadcastReceiver extends B roadcastReceiver {private s t a t i c f i n a l S t r i n g TAG = ” USBBroadcastReceiver ” ;/∗∗∗ The a c t i v i t y t h a t s t a r t e d us .∗/private USBMonitorActivity a c t i v i t y = null ;/∗∗∗ @param parent∗ The a c t i v i t y t h a t s t a r t e d us and w i l l g e t∗ t h e l o g messages .∗/public USBBroadcastReceiver ( USBMonitorActivity parent ) {a c t i v i t y = parent ;}/∗∗∗ @see android . c o n t e n t . BroadcastReceiver#∗ onReceive ( android . c o n t e n t . Context ,∗ android . c o n t e n t . I n t e n t )∗/@Overridepublic void onReceive ( Context context , I n t e n t i n t e n t ) {// This i s t h e CyanogenMod 7.1 UsbManager , not t h e one// from s t o c k Android 2.3 or t h e b a c k p o r t e d Google// API : s .i f ( i n t e n t . getAction ( ) . e q u a l s (UsbManager . ACTION USB STATE) ) {68

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!