如何在三星Galaxy S10或S10 +中测试接近传感器?

我想在三星新型号(s10或s10 +)上测试接近传感器,我使用旧的传统方法为接近传感器注册侦听器,并且它适用于除这2个设备之外的所有设备。我在互联网上搜索过,并了解到S10在显示屏下有接近传感器(在通话期间闪烁的像素亮起等)。我还使用过许多第三方传感器测试应用程序,但没有一个适用于S10。有谁知道三星改变了什么?我们如何以编程方式访问S10接近传感器?我已经尝试了下面的代码,但它总是令人敬酒。


@Override

   public void onSensorChanged(SensorEvent event) {

       if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) {

           if (event.values[0] >= -SENSOR_SENSITIVITY && event.values[0] <= SENSOR_SENSITIVITY) {

               //near

               Toast.makeText(getApplicationContext(), "near", Toast.LENGTH_SHORT).show();

           } else {

               //far

               Toast.makeText(getApplicationContext(), "far", Toast.LENGTH_SHORT).show();

           }

       }

   }


   @Override

   public void onAccuracyChanged(Sensor sensor, int accuracy) {

       Toast.makeText(getApplicationContext(), "accuracy changed", Toast.LENGTH_SHORT).show();

   }


蝴蝶刀刀
浏览 172回答 4
4回答

慕田峪9158850

您可以使用密码*#77692#在三星Galaxy S10上测试接近传感器

FFIVE

尽量不要直接使用传感器 API。要测试接近传感器,只需获取使用PROXIMITY_SCREEN_OFF_WAKE_LOCK参数创建的唤醒锁即可。获取测量的距离无济于事,但是当您将手掌放在传感器上时,屏幕将开始关闭/打开。class ProximityMgr(context: Context) {&nbsp; &nbsp; private val powerManager: PowerManager = context.getSystemService()!!&nbsp; &nbsp; private val wakeLock: PowerManager.WakeLock&nbsp; &nbsp; init {&nbsp; &nbsp; &nbsp; &nbsp; wakeLock = powerManager.newWakeLock(&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "lock:proximity_screen_off")&nbsp; &nbsp; }&nbsp; &nbsp; fun acquire() {&nbsp; &nbsp; &nbsp; &nbsp; if (powerManager.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (wakeLock.isHeld) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wakeLock.release()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wakeLock.acquire(WAKE_LOCK_TIMEOUT_MS)&nbsp; &nbsp; &nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.w(TAG, "not supported")&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; fun release() {&nbsp; &nbsp; &nbsp; &nbsp; if (wakeLock.isHeld)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wakeLock.release()&nbsp; &nbsp; }&nbsp; &nbsp; companion object {&nbsp; &nbsp; &nbsp; &nbsp; private const val TAG = "ProximitySensor"&nbsp; &nbsp; &nbsp; &nbsp; private const val WAKE_LOCK_TIMEOUT_MS: Long = 2 * 3600 * 1000&nbsp; &nbsp; }}这个片段取自这个答案。

qq_花开花谢_0

下面介绍如何打开和测试接近传感器。拨打 *#77692# 您将获得两个传感器进行测试:1:光传感器 2:接近传感器您无法将其打开并保持打开状态。我们可以通过打开它来测试它,然后它进入关闭模式。三星非常奇怪。也许下一次更新将提供保持它的可能性。因此,屏幕不会在口袋中解锁。希望这可以帮助你。

ITMISS

简单来说(非程序化)方法1星形哈希零星形哈希(#0#)在拨号器上 选择接近传感器时将出现一个选项块(红色,绿色,蓝色,振动,相机)现在它将显示勒克斯(发光强度)量更多光更勒克斯.方法2 做一个电话。在通话过程中,显示屏本身的右上方区域(相机左侧)将出现一个白点闪烁。(看起来像一个像素点).现在悬停并检查。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java