代码之家  ›  专栏  ›  技术社区  ›  Andy Jazz

该应用在华为手机上检测到陀螺仪,但网站上说:“没有陀螺仪”

  •  0
  • Andy Jazz  · 技术社区  · 6 年前

    Huawei P Smart 2019 智能手机。大多数有规格的网站(包括华为官方网站)都表示 没有陀螺仪 在这个模型中。

    但我做了测试 华为P智能2019 使用传感器融合应用程序。该应用程序检测陀螺仪传感器并显示其工作原理。

    有什么问题吗?为什么连制造商都说 无陀螺仪传感器 在里面 华为P智能2019 虽然 传感器显然存在 那里

    也许这是一个 virtual gyroscope ?

    package org.hitlabnz.sensor_fusion_demo;
    
    public class SensorSelectionActivity extends FragmentActivity {
        SectionsPagerAdapter mSectionsPagerAdapter;
        ViewPager mViewPager;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_sensor_selection);
            mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
            mViewPager = (ViewPager) findViewById(R.id.pager);
            mViewPager.setAdapter(mSectionsPagerAdapter);
    
            SensorChecker checker = new HardwareChecker((SensorManager) getSystemService(SENSOR_SERVICE));
            if(!checker.IsGyroscopeAvailable()) {
                displayHardwareMissingWarning();
            }
        }
        private void displayHardwareMissingWarning() {
            AlertDialog ad = new AlertDialog.Builder(this).create();  
            ad.setCancelable(false);   
            ad.setTitle(getResources().getString(R.string.gyroscope_missing)); 
            ad.setMessage(getResources().getString(R.string.gyroscope_missing_message));
    
            ad.setButton(DialogInterface.BUTTON_NEUTRAL, getResources().getString(R.string.OK), new DialogInterface.OnClickListener() {  
                @Override  
                public void onClick(DialogInterface dialog, int which) {   
                    dialog.dismiss();                      
                }  
            });  
            ad.show();  
        }
    }
    
    0 回复  |  直到 5 年前
        1
  •  1
  •   Benjamin    6 年前

    关于它是如何工作的一点解释: https://android.gadgethacks.com/how-to/use-google-cardboard-if-your-phone-doesnt-have-gyroscope-0172650/

    通过智能手机上的指南针和加速度传感器,你可以制作一个虚拟陀螺仪。你需要从指南针和加速器获取数据,并对其进行大量工作和排序,但你可以通过它虚拟地处理陀螺仪功能:-)