0

I'm trying to connect Google Glass with an Android device over USB. But when I connect them over USB, the Android device is working fine and its BroadcastReceiver onReceive() run, but on the other hand Google Glass BroadcastReceiver onReceive() method never get called.

The code that works is below:

in onResume() :

 registerReceiver(mUsbDeviceReceiver, new intentFilter(UsbManager.ACTION_USB_DEVICE_ATTACHED));

Broadcast:

private final BroadcastReceiver mUsbDeviceReceiver = new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
            // some code...
        } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
            // some code...
        } else {
            // some code...
        }
    }
    };   

Below is the Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.usb.glass"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="19"
    android:targetSdkVersion="19" />

  <uses-feature android:name="android.hardware.usb.host" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.usb.glass.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
        </intent-filter>


        <!-- <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
            android:resource="@xml/device_filter" />  -->
    </activity>


</application>

</manifest>

Any help?

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Gurmail
  • 51
  • 3

0 Answers0