Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 吊死_Android_Android Activity_Accelerometer - Fatal编程技术网

Android 吊死

Android 吊死,android,android-activity,accelerometer,Android,Android Activity,Accelerometer,嗨,这是我从链接中获取的代码 但“活动”并没有显示任何内容,只是一个空白屏幕,也会挂起。 有谁能帮上忙吗? 谢谢我已经复制了您的代码并编译/运行了它,我的手机和模拟器都没有问题,如图1和图2所示 值得注意的是,蓝色椭圆在emulator上保持静态,因为emulator没有加速度计。另一方面,当我移动或摇动手机时,蓝色椭圆形在矩形内保持动态。如果椭圆形手机仍然保持静止,你应该检查你的硬件和软件。硬件是指手机上的加速计芯片,而软件是指加速计的驱动程序和HAL 安装诸如“”之类的应用程序很容易,以检查

嗨,这是我从链接中获取的代码

但“活动”并没有显示任何内容,只是一个空白屏幕,也会挂起。 有谁能帮上忙吗?
谢谢

我已经复制了您的代码并编译/运行了它,我的手机和模拟器都没有问题,如图1和图2所示

值得注意的是,蓝色椭圆在emulator上保持静态,因为emulator没有加速度计。另一方面,当我移动或摇动手机时,蓝色椭圆形在矩形内保持动态。如果椭圆形手机仍然保持静止,你应该检查你的硬件和软件。硬件是指手机上的加速计芯片,而软件是指加速计的驱动程序和HAL

安装诸如“”之类的应用程序很容易,以检查您是否可以从加速计读取3轴值。您还可以在logcat中查看日志以检查传感器服务

我的AndroidManifest.xml如下所示

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.so_problem"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.so_problem.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

图1在emulator上运行。

图2在我的手机上运行。

我认为您应该提供logcat。另外,也许你们可以在emulator上测试你们的应用程序?是的,我在emulator上运行它。。你能帮我修改上面的代码吗?添加一个背景线程,休眠100 ms,然后唤醒并检查加速计,然后休眠。我认为您应该自己执行此操作,如果您遇到特定错误,可以询问我们。这就是这项服务的工作原理。在模拟器中,您没有加速计,因此我对您出现错误并不感到惊讶。你应该在一个真实的设备上测试这个功能。yuvry加速度计有默认的延迟状态,而不是我必须为它创建线程并延迟几秒钟?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.so_problem"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.so_problem.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>