gpt4 book ai didi

android - 单击并按住耳机按钮无任何 Action

转载 作者:行者123 更新时间:2023-11-29 01:39:13 25 4
gpt4 key购买 nike

我有一个 BroadcastReceiver,我的目标是检测对耳机按钮的长按。尝试了不同的版本,但都没有用。所以现在我正在尝试检查收到的操作。如果我正常单击,我可以看到操作 0 (KeyDown) 和 1 (KeyUp)。如果我单击并按住,则不会显示任何内容,无论是按下还是向上。怎么了?

@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
Log.e("action",""+event.getAction());
...
}
}

如果需要,我可以发布更多代码,但我认为这不相关

在装有 Android 4.3 的 S4 上运行。不确定这是否重要,S-Voice 被卡住,Google Now 被禁用。我注意到,如果我的屏幕关闭并长按,我会看到一个菜单“使用 Google 搜索/AutoVoice 处理长按”

最佳答案

我认为您可以使用 list 中的这段代码来控制长按。这将打开一个对话框,让您选择要使用长按的应用程序。当手机解锁时它对我有用,但当手机锁定时它不会工作。它会弹出对话框,但当您解锁手机时它会消失。希望我能得到一些帮助。

关键是打开“Activity”而不是实现广播接收器。

   <activity 
android:name="packagename.activityname"
android:launchMode="singleInstance"
android:showOnLockScreen="true">
<intent-filter android:priority="2147483647">
<action android:name="android.speech.action.WEB_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="2147483647">
<action android:name="android.speech.action.VOICE_SEARCH_HANDS_FREE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.sec.action.SVOICE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

我已经在 Kitkat 上测试过了。不知道以前的版本会发生什么。

关于android - 单击并按住耳机按钮无任何 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25827595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com