【发布时间】:2016-05-03 14:09:45
【问题描述】:
所以我有一个蓝牙设备,我听设备上的按钮按下,并在按下按钮时尝试拍照。问题是我没有找到任何解决方案。
} else if (destination.equals(APPLICATION_ACTION_DESTINATION_OPEN_CAMERA)) {
Intent intent1 = new Intent("android.intent.action.CAMERA_BUTTON");
intent1.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(0, KeyEent.KEYCODE_CAMERA));
context.sendOrderedBroadcast(intent1, null);
intent1 = new Intent("android.intent.action.CAMERA_BUTTON");
intent1.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(1, KeyEvent.KEYCODE_CAMERA));
context.sendOrderedBroadcast(intent1, null);
} else if (destination.equals(APPLICATION_ACTION_DESTINATION_TAKE_PHOTO)) {
}
我发现这样做的唯一方法是使用:
Instrumentation.sendKeyDownUpSync();
问题是我需要注册仅授予系统应用程序的 INJECT_EVENTS 权限。
有人能做到吗?
【问题讨论】:
-
Android 设备型号数以千计。它们附带数百个预装的相机应用程序,还有数百个可从 Play 商店和其他地方安装。无需为外部应用程序提供任何方式来控制何时拍照。
-
我尝试模拟硬件音量增大按钮,但不是针对所有可能的应用程序
-
@Tazz 你做到了吗?我面临着类似的问题。
-
@Tazz 我也尝试过你在找到这个之前所做的事情。你找到替代方法了吗?请告诉我们。我现在的尝试是使用 root 权限使应用程序本身成为系统应用程序
-
@WuerfelDev 不,我没有,功能被划伤了
标签: android android-intent android-camera android-bluetooth android-event