广播接收器LONG_TAP com.google.glass.action.LONG_TAP不工作



我试图收听广播,LONG_TAP以覆盖谷歌搜索。我希望我的应用程序定义一个LONG_TAP手势。请提出替代方法或解决方案...法典:

    @Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    if (intent.getAction().equals("com.google.glass.action.LONG_TAP")) {
        //abortBroadcast();
        System.out.println("Yaay..!!! could listen to the long tap");
        //abortBroadcast();
    }
}

好吧,事实证明,更高版本的谷歌眼镜已将LONG_TAP更改为LONG_PRESS所以代码去

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    if (intent.getAction().equals("com.google.glass.action.LONG_PRESS")) {
        //abortBroadcast();
        System.out.println("Yaay..!!! could listen to the long tap");
        //abortBroadcast();
    }
}

和安卓清单

<receiver android:name="HeadOnBroadCastReceiver" android:exported="false">
    <intent-filter android:priority="1000" >
        <action android:name="com.google.glass.action.LONG_PRESS" />
    </intent-filter>
</receiver>

但是当设备处于睡眠状态时,它仍然无法工作。如果您有更好的解决方案可以在设备睡眠时工作,请回复....并感谢迈克·迪乔瓦尼的帮助

最新更新