1
 mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
     am = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
     if(mSensorManager.getSensorList(SensorManager.SENSOR_PROXIMITY).size()>0)
     {
         hasproximity=true;
         psensor=mSensorManager.getDefaultSensor(SensorManager.SENSOR_PROXIMITY);
         mSensorManager.registerListener(this,psensor,SensorManager.SENSOR_DELAY_NORMAL);
     }
     else
     {
         hasproximity=false;
         Toast.makeText(getApplicationContext(),"No Proximity Sensor",Toast.LENGTH_SHORT).show();
         stopSelf();
     }

这是我用于访问接近传感器的代码,但我收到一个 toast 通知,提示没有接近传感器可用,但我的手机索尼 xperia j 有接近传感器

谁能帮我

访问接近传感器是否需要任何使用许可?我尝试在没有任何使用预授权标签的情况下访问加速度计传感器,这对我来说效果很好

4

0 回答 0