将 Android 运动传感器设置为数组并显示值
我正在寻求帮助。我参加了 Android 编程课程,我们需要构建一个应用程序,将传感器数据(加速度计、陀螺仪和磁场)放入数组中,并显示值。不幸的是,我只懂基础的Java,感觉有些逻辑有些卡壳。
我通过显示传感器的实时值启动了我的应用程序。我已经成功了,但是噪音太大而且不准确。因此,我尝试将从传感器生成的值存储到数组中,然后在 TextView 中显示这些值。现在,当我运行该应用程序时,它只会崩溃。我不确定我缺少什么,但这可能是一些 Java 逻辑。 总的来说,我已经正确设置了用户界面。我有 MainActivity.java 和单独的 java 类来收集使用 getter 和 setter 设置的传感器数据。
MainActivity代码:
package com.example.servicesassignmentone;
import androidx.appcompat.app.AppCompatActivity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements SensorEventListener{
private Button myButton;
Handler myHandler = new Handler();
private TextView accelerometerX, accelerometerY, accelerometerZ;
private SensorManager sensorManager;
private Sensor sensorAccelerometer;
private boolean sensorAccelerometerSet = false;
private List<Accelerometer> accelerometerListValues = new ArrayList<Accelerometer>();
private TextView gyroscopeX, gyroscopeY, gyroscopeZ;
private Sensor sensorGyroscope;
private boolean sensorGyroscopeSet = false;
private List<Gyroscope> gyroscopeLastValues = new ArrayList<Gyroscope>();
private TextView magFieldX, magFieldY, magFieldZ;
private Sensor sensorMagField;
private boolean sensorMagFieldSet = false;
private List<MagField> magFieldLastValues = new ArrayList<MagField>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// button and UI initialization
myButton = (Button) findViewById(R.id.myButton);
//Accelerometer
accelerometerX = (TextView) findViewById(R.id.textViewAccX);
accelerometerY = (TextView) findViewById(R.id.textViewAccY);
accelerometerZ = (TextView) findViewById(R.id.textViewAccZ);
//Gyroscope
gyroscopeX = (TextView) findViewById(R.id.textViewGyroX);
gyroscopeY = (TextView) findViewById(R.id.textViewGyroY);
gyroscopeZ = (TextView) findViewById(R.id.textViewGyroZ);
//Magnetic Field
magFieldX = (TextView) findViewById(R.id.textViewMagX);
magFieldY = (TextView) findViewById(R.id.textViewMagY);
magFieldZ = (TextView) findViewById(R.id.textViewMagZ);
// initializing the sensor manager
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
// initializing the different sensors
sensorAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sensorGyroscope = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
sensorMagField = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.myButton:
sensorManager.registerListener((SensorEventListener) MainActivity.this, sensorAccelerometer, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) MainActivity.this, sensorGyroscope, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) MainActivity.this, sensorMagField, SensorManager.SENSOR_DELAY_FASTEST);
break;
}
}
});
}
@Override
protected void onResume() {
super.onResume();
sensorAccelerometerSet = false;
sensorGyroscopeSet = false;
sensorMagFieldSet = false;
sensorManager.registerListener((SensorEventListener) this, sensorAccelerometer, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) this, sensorGyroscope, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) this, sensorMagField, SensorManager.SENSOR_DELAY_FASTEST);
}
@Override
protected void onPause() {
super.onPause();
sensorManager.unregisterListener((SensorEventListener) this);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
//Using the arraylist
Float accelerValuesX, accelerValuesY, accelerValuesZ;
Float gyroValuesX, gyroValuesY, gyroValuesZ;
Float magValuesX, magValuesY, magValuesZ;
//if (accelerometerListValues.size() >= 500 && gyroscopeLastValues.size() >= 500 && magFieldLastValues.size() >= 500) {
//}
if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
accelerValuesX = sensorEvent.values[0];
accelerValuesY = sensorEvent.values[1];
accelerValuesZ = sensorEvent.values[2];
accelerometerListValues.add(new Accelerometer(accelerValuesX, accelerValuesY, accelerValuesZ));
for (int i = 0; i < accelerometerListValues.size(); i++) {
Accelerometer output = accelerometerListValues.get(i);
accelerometerX.setText((CharSequence) output);
}
}
if (sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
gyroValuesX = sensorEvent.values[0];
gyroValuesY = sensorEvent.values[1];
gyroValuesZ = sensorEvent.values[2];
gyroscopeLastValues.add(new Gyroscope(gyroValuesX, gyroValuesY, gyroValuesZ));
for (int i = 0; i < gyroscopeLastValues.size(); i++) {
Gyroscope output = gyroscopeLastValues.get(i);
gyroscopeX.setText((CharSequence) output);
}
}
if (sensorEvent.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
magValuesX = sensorEvent.values[0];
magValuesY = sensorEvent.values[1];
magValuesZ = sensorEvent.values[2];
magFieldLastValues.add(new MagField(magValuesX, magValuesY, magValuesZ));
for (int i = 0; i < magFieldLastValues.size(); i++) {
MagField output = magFieldLastValues.get(i);
magFieldX.setText((CharSequence) output);
}
}
调试日志很长: --------- 崩溃开始 2022-03-07 20:42:59.962 28780-28780/com.example.servicesassignmentone E/AndroidRuntime: 致命异常: main 进程:com.example.servicesassignmentone,PID:28780 java.lang.ClassCastException:com.example.servicesassignmentone.Accelerometer 无法转换为 java.lang.CharSequence 在 com.example.servicesassignmentone.MainActivity.onSensorChanged(MainActivity.java:120) 在 android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:900) 在 android.os.MessageQueue.nativePollOnce(本机方法) 在 android.os.MessageQueue.next(MessageQueue.java:342) 在 android.os.Looper.loop(Looper.java:197) 在 android.app.ActivityThread.main(ActivityThread.java:7803) 在 java.lang.reflect.Method.invoke(本机方法) 在 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) 2022-03-07 20:42:59.970 2108-28828/? I/DropBoxManagerService:添加标签=data_app_crash isTagEnabled=true 标志=0x2 2022-03-07 20:42:59.971 2108-3891/? W/ActivityTaskManager:强制完成活动 com.example.servicesassignmentone/.MainActivity 2022-03-07 20:43:00.011 2108-2282/? W/BroadcastQueue:不允许后台执行:接收 Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } 到 com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver 2022-03-07 20:43:00.012 2108-2282/? W/BroadcastQueue:不允许后台执行:接收 Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } 到 com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver 2022-03-07 20:43:00.018 28780-28780/com.example.servicesassignmentone I/Process:发送信号。 PID:28780 SIG:9 2022-03-07 20:43:00.030 5605-5638/? W/DynamicVolume-DynamicVolumeService:onForegroundActivitiesChanged,但功能未打开,忽略! 2022-03-07 20:43:00.059 1106-1218/? E/qdmetadata:不支持 paramType 2048 2022-03-07 20:43:00.068 2108-9083/? I/ActivityManager:进程 com.example.servicesassignmentone (pid 28780) 已死亡:prcp TOP 2022-03-07 20:43:00.069 2108-3891/? I/WindowManager:胜利死亡:窗口{6c0ef4 u0 com.example.servicesassignmentone/com.example.servicesassignmentone.MainActivity} 2022-03-07 20:43:00.069 2108-3891/? W/InputDispatcher:尝试取消注册已取消注册的输入通道“6c0ef4 com.example.servicesassignmentone/com.example.servicesassignmentone.MainActivity(服务器)” 2022-03-07 20:43:00.069 1097-1097/? I/sensors-hal:批次:242,android.sensor.accelerometer/11,周期=200000000,max_latency=0 2022-03-07 20:43:00.069 1097-1097/? I/sensors-hal: set_config:63,sample_period_ns根据min/maxdelay_ns调整为200000000 2022-03-07 20:43:00.069 1097-1097/? I/sensors-hal: 批次:251, android.sensor.accelerometer/11, period=200000000, max_latency=0 请求已完成 2022-03-07 20:43:00.071 1097-1097/? I/sensors-hal:激活:209,android.sensor.Magnetic_field/21 en=0 2022-03-07 20:43:00.075 1097-28701/? I/传感器-hal:ssc_conn_resp_cb:654,resp_value = 0 2022-03-07 20:43:00.076 1097-1097/? E/Diag_Lib:诊断:Diag_LSM_DeInit 已完成 pid:1097 2022-03-07 20:43:00.076 1097-1097/? I/sensors-hal: activate:220, android.sensor.Magnetic_field/21 en=0 已完成 2022-03-07 20:43:00.076 1097-1097/? I/sensors-hal:激活:209,android.sensor.gyrscope/41 en=0 2022-03-07 20:43:00.078 1195-1219/? E/adsprpcd:供应商/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:596:错误0xffffffff:apps_std getenv失败:ADSP_LIBRARY_PATH未知错误-1 2022-03-07 20:43:00.079 1195-1219/? I/adsprpcd:vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:777:已成功打开文件/mnt/vendor/persist/sensors/registry/temp.json 2022-03-07 20:43:00.082 1097-1097/? E/Diag_Lib:诊断:Diag_LSM_DeInit 已完成 pid:1097 2022-03-07 20:43:00.083 1195-1219/? E/adsprpcd:供应商/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:596:错误0xffffffff:apps_std getenv失败:ADSP_LIBRARY_PATH未知错误-1 2022-03-07 20:43:00.083 1195-1219/? I/adsprpcd:vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:777:已成功打开文件/mnt/vendor/persist/sensors/registry/temp.json 2022-03-07 20:43:00.083 1097-1097/? E/Diag_Lib:诊断:Diag_LSM_DeInit 已完成 pid:1097 2022-03-07 20:43:00.083 1097-1097/? I/sensors-hal: activate:220, android.sensor.gyrscope/41 en=0 已完成 2022-03-07 20:43:00.088 1001-1001/? I/Zygote:进程 28780 由于信号 9(已终止)而退出 2022-03-07 20:43:00.099 2108-2315/? I/libprocessgroup:在 29 毫秒内成功杀死进程 cgroup uid 10298 pid 28780 2022-03-07 20:43:00.109 3818-3838/? I/ndroid.systemu:NativeAlloc并发复制GC释放了13956(730KB)个AllocSpace对象,0(0B)个LOS对象,49%空闲,8443KB/16MB,暂停76us总计105.730ms 2022-03-07 20:43:00.122 3818-3844/? W/系统:资源无法调用释放。 2022-03-07 20:43:00.131 2108-2259/? W/ActivityManager:在未知 pid 上调用 setHasOverlayUi:28780 2022-03-07 20:43:00.145 2108-2260/? I/WindowManager: SURFACE 显示 Surface(name=com.android.systemui.ImageWallpaper)/@0x704dd96 显示:0 2022-03-07 20:43:00.146 2108-2259/? E/SystemServiceRegistry:没有发布服务:payjoy_access_service android.os.ServiceManager$ServiceNotFoundException:没有发布服务:payjoy_access_service 在 android.os.ServiceManager.getServiceOrThrow(ServiceManager.java:153) 在 android.app.SystemServiceRegistry$126.createService(SystemServiceRegistry.java:1694) 在 android.app.SystemServiceRegistry$StaticServiceFetcher.getService(SystemServiceRegistry.java:1919) 在 android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:1517) 在 android.app.ContextImpl.getSystemService(ContextImpl.java:1938) 在com.android.server.wm.ActivityStack.shouldSendPayJoyBroadcast(ActivityStack.java:3644) 在 com.android.server.wm.ActivityStack.access$000(ActivityStack.java:188) 在 com.android.server.wm.ActivityStack$ActivityStackHandler.handleMessage(ActivityStack.java:316) 在 android.os.Handler.dispatchMessage(Handler.java:106) 在 android.os.Looper.loop(Looper.java:250) 在 android.os.HandlerThread.run(HandlerThread.java:67) 在 com.android.server.ServiceThread.run(ServiceThread.java:44) 2022-03-07 20:43:00.146 2108-2259/? E/SystemServiceRegistry:管理器包装不可用:payjoy_access_service 2022-03-07 20:43:00.148 2108-2260/? I/WindowManager: SURFACE 显示 Surface(name=com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher)/@0x43cd0d3 显示:0 2022-03-07 20:43:00.148 2108-2260/? I/WindowManager: SURFACE 显示 Surface(name=com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher)/@0xbb76410 显示:0 2022-03-07 20:43:00.157 5263-5263/? I/GsaVoiceInteractionSrv:处理 ACTION_START_HOTWORD 2022-03-07 20:43:00.160 1106-1218/? E/qdmetadata:不支持 paramType 2048 2022-03-07 20:43:00.160 1106-1218/? E/qdmetadata:不支持 paramType 2048 2022-03-07 20:43:00.161 5263-5933/? I/GsaVoiceInteractionSrv: disregardVoiceMatch: false 2022-03-07 20:43:00.162 5263-5933/? I/GsaVoiceInteractionSrv:无法启动热词,热词已被明确禁用。 2022-03-07 20:43:00.167 1111-1111/? I/QTI PowerHAL:电源设置模式:5 至:0 2022-03-07 20:43:00.168 5103-5103/?我/GoogleInputMethodService:GoogleInputMethodService.onFinishInput():3210 2022-03-07 20:43:00.175 5103-5103/? I/GoogleInputMethodService:GoogleInputMethodService.updateDeviceLockedStatus():2099 checkRepeatedly = false,解锁= true 2022-03-07 20:43:00.175 5103-5103/? I/GoogleInputMethodService: GoogleInputMethodService.onStartInput():1907 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0initialSelStart=-1initialSelEnd=-1initialCapsMode=0x0hintText=null标签=null 包名=com.motorola.launcher3 fieldId=-1 fieldName=null extras=null}, false) 2022-03-07 20:43:00.177 5103-5103/? I/GoogleInputMethodService:GoogleInputMethodService.updateDeviceLockedStatus():2099 checkRepeatedly = true,解锁= true 2022-03-07 20:43:00.263 5537-5556/? D/AssistReceiver:调用:lightWakeup |空 |无效的 2022-03-07 20:43:00.284 1106-1218/? E/qdmetadata:不支持 paramType 2048 2022-03-07 20:43:00.476 2108-2259/? W/ActivityTaskManager:ActivityRecord{c3cd9a0 u0 com.example.servicesassignmentone/.MainActivity t-1 f}} 的 Activity 顶部恢复状态丢失超时 2022-03-07 20:43:00.484 4941-4941/? D/游戏模式:isScreenUnlocked:true 2022-03-07 20:43:00.486 4941-4941/? D/GameMode:退出游戏模式 2022-03-07 20:43:00.491 4941-4941/? D/游戏模式:重置:假 2022-03-07 20:43:00.491 4941-4941/? D/游戏模式:重置: 2022-03-07 20:43:00.491 4941-4941/? D/GameMode: isFeatureSupported: false 2022-03-07 20:43:00.495 4941-7481/? D/MFL:getFreeFormPackages:为空 2022-03-07 20:43:00.496 4941-7481/? D/MFL:getDensityIndependentPixel:最小宽度= 411 2022-03-07 20:43:00.497 4941-7481/? D/MFL: getLaunchRect: 边距 = 0 2022-03-07 20:43:00.708 22132-22132/? W/DetectPable:类型= 1400审核(0.0:135965):avc:拒绝{getattr} for path =“/ proc/fb”dev =“proc”ino = 4026531964 scontext = u:r:shell:s0 tcontext = u: object_r:proc:s0 tclass=文件许可=0 2022-03-07 20:43:00.708 22132-22132/? W/DetectPable:类型= 1400审核(0.0:135966):avc:拒绝{getattr} for path =“/ proc/keys”dev =“proc”ino = 4026532156 scontext = u:r:shell:s0 tcontext = u: object_r:proc_keys:s0 tclass=文件许可=0 2022-03-07 20:43:00.708 22132-22132/? W/DetectPable:类型= 1400审核(0.0:135967):avc:拒绝{getattr} for path =“/ proc/kmsg”dev =“proc”ino = 4026532061 scontext = u:r:shell:s0 tcontext = u: object_r:proc_kmsg:s0 tclass=文件许可=0 2022-03-07 20:43:00.708 22132-22132/? W/DetectPable:类型= 1400审核(0.0:135968):avc:拒绝{getattr} for path =“/ proc/misc”dev =“proc”ino = 4026531965 scontext = u:r:shell:s0 tcontext = u: object_r:proc_misc:s0 tclass=文件许可=0 2022-03-07 20:43:00.708 22132-22132/? W/DetectPable:类型= 1400审核(0.0:135969):avc:拒绝{getattr} for path =“/ proc/iomem”dev =“proc”ino = 4026532140 scontext = u:r:shell:s0 tcontext = u: object_r:proc_iomem:s0 tclass=文件许可=0 2022-03-07 20:43:01.768 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136005):avc:拒绝{getattr} for path =“/ proc/fb”dev =“proc”ino = 4026531964 scontext = u:r:shell:s0 tcontext = u: object_r:proc:s0 tclass=文件许可=0 2022-03-07 20:43:01.768 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136006):avc:拒绝{ getattr } for path =“/ proc/keys”dev =“proc”ino = 4026532156 scontext = u:r:shell:s0 tcontext = u: object_r:proc_keys:s0 tclass=文件许可=0 2022-03-07 20:43:01.768 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136007):avc:拒绝{getattr} for path =“/ proc/kmsg”dev =“proc”ino = 4026532061 scontext = u:r:shell:s0 tcontext = u: object_r:proc_kmsg:s0 tclass=文件许可=0 2022-03-07 20:43:01.773 1112-1137/?我/[电子邮件受保护]:为传感器触发的 uevent:msm_therm 2022-03-07 20:43:01.768 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136008):avc:拒绝{getattr} for path =“/ proc/misc”dev =“proc”ino = 4026531965 scontext = u:r:shell:s0 tcontext = u: object_r:proc_misc:s0 tclass=文件许可=0 2022-03-07 20:43:01.771 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136009):avc:拒绝{getattr} for path =“/ proc/iomem”dev =“proc”ino = 4026532140 scontext = u:r:shell:s0 tcontext = u: object_r:proc_iomem:s0 tclass=文件许可=0 2022-03-07 20:43:02.828 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136045):avc:拒绝{getattr} for path =“/ proc/fb”dev =“proc”ino = 4026531964 scontext = u:r:shell:s0 tcontext = u: object_r:proc:s0 tclass=文件许可=0 2022-03-07 20:43:02.828 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136046):avc:拒绝{ getattr } for path =“/ proc/keys”dev =“proc”ino = 4026532156 scontext = u:r:shell:s0 tcontext = u: object_r:proc_keys:s0 tclass=文件许可=0 2022-03-07 20:43:02.828 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136047):avc:拒绝{getattr} for path =“/ proc/kmsg”dev =“proc”ino = 4026532061 scontext = u:r:shell:s0 tcontext = u: object_r:proc_kmsg:s0 tclass=文件许可=0 2022-03-07 20:43:02.828 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136048):avc:拒绝{getattr} for path =“/ proc/misc”dev =“proc”ino = 4026531965 scontext = u:r:shell:s0 tcontext = u: object_r:proc_misc:s0 tclass=文件许可=0 2022-03-07 20:43:02.828 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136049):avc:拒绝{getattr} for path =“/ proc/iomem”dev =“proc”ino = 4026532140 scontext = u:r:shell:s0 tcontext = u: object_r:proc_iomem:s0 tclass=文件许可=0 2022-03-07 20:43:02.954 1097-2576/? I/slpi:ALS_OC LUX:6.20,比例:0.99,CH0:50,CH1:54,AT:198.80,AG:138 2022-03-07 20:43:03.142 5966-6209/? I/WorkerManager:dispose() 2022-03-07 20:43:03.150 1097-2576/? I/slpi:ALS_OC LUX:5.10,比例:0.99,CH0:40,CH1:39,AT:198.80,AG:138 2022-03-07 20:43:03.346 2108-2574/? D /电池服务:uevent = {POWER_SUPPLY_DP_DM = 0,POWER_SUPPLY_TEMP_HOT = 0,POWER_SUPPLY_VOLTAGE_QNOVO = -22,POWER_SUPPLY_VOLTAGE_NOW = 4373493,POWER_SUPPLY_SW_JEITA_ENABLED = 0, POWER_SUPPLY_CHARGE_CONTROL_LIMIT_MAX=8、POWER_SUPPLY_RECHARGE_SOC=99、POWER_SUPPLY_HEALTH=良好、POWER_SUPPLY_TECHNOLOGY=锂离子、POWER_SUPPLY_CHARGER_TEMP_MAX=800、POWER_SUPPLY_CHARGE_FULL_DESIGN=4100000、 POWER_SUPPLY_FCC_STEPPER_ENABLE=0、SEQNUM=20602、POWER_SUPPLY_INPUT_CURRENT_LIMITED=0、POWER_SUPPLY_CHARGE_CONTROL_LIMIT=0、POWER_SUPPLY_STATUS=已满、POWER_SUPPLY_CURRENT_MAX=0、POWER_SUPPLY_CYCLE_COUNT=0、 POWER_SUPPLY_CHARGE_TERM_CURRENT=-102,POWER_SUPPLY_CAPACITY=100, DEVPATH=/devices/platform/soc/1c40000.qcom、spmi/spmi-0/spmi0-02/1c40000.qcom、spmi:qcom、pmi632@2:qcom、qpnp-smb5-mmi/power_supply/电池、POWER_SUPPLY_CHARGE_DONE=1 , POWER_SUPPLY_CHARGE_TYPE=N/A、POWER_SUPPLY_CHARGER_TEMP=290、POWER_SUPPLY_CHARGE_RATE=正常、POWER_SUPPLY_CURRENT_QNOVO=-22、POWER_SUPPLY_CURRENT_NOW=0、POWER_SUPPLY_PRESENT=1、POWER_SUPPLY_PARALLEL_DISABLE=0、 POWER_SUPPLY_CHARGE_FULL=4104000、POWER_SUPPLY_CONSTANT_CHARGE_CURRENT=0、SUBSYSTEM=power_supply、POWER_SUPPLY_SET_SHIP_MODE=0、POWER_SUPPLY_TEMP=267、ACTION=更改、POWER_SUPPLY_RERUN_AICL=0、POWER_SUPPLY_NAME=电池、 POWER_SUPPLY_VOLTAGE_MAX=-22、POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3600000、POWER_SUPPLY_CHARGE_COUNTER=4104000、POWER_SUPPLY_STEP_CHARGING_ENABLED=0、POWER_SUPPLY_DIE_HEALTH=酷、 POWER_SUPPLY_INPUT_SUSPEND=0} 2022-03-07 20:43:03.885 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136085):avc:拒绝{getattr} for path =“/ proc/fb”dev =“proc”ino = 4026531964 scontext = u:r:shell:s0 tcontext = u: object_r:proc:s0 tclass=文件许可=0 2022-03-07 20:43:03.885 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136086):avc:拒绝{getattr} for path =“/ proc/keys”dev =“proc”ino = 4026532156 scontext = u:r:shell:s0 tcontext = u: object_r:proc_keys:s0 tclass=文件许可=0 2022-03-07 20:43:03.885 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136087):avc:拒绝{getattr} for path =“/ proc/kmsg”dev =“proc”ino = 4026532061 scontext = u:r:shell:s0 tcontext = u: object_r:proc_kmsg:s0 tclass=文件许可=0 2022-03-07 20:43:03.885 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136088):avc:拒绝{getattr} for path =“/ proc/misc”dev =“proc”ino = 4026531965 scontext = u:r:shell:s0 tcontext = u: object_r:proc_misc:s0 tclass=文件许可=0 2022-03-07 20:43:03.885 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136089):avc:拒绝{getattr} for path =“/ proc / iomem”dev =“proc”ino = 4026532140 scontext = u:r:shell:s0 tcontext = u: object_r:proc_iomem:s0 tclass=文件许可=0 2022-03-07 20:43:04.696 4875-28832/? I/Authzen:[DeviceStateSyncManager] 服务器与当前状态同步。无事可做 2022-03-07 20:43:04.726 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl $TaskRunnerJobService.onStartJob():204 onStartJob():mdd_periodical_task_MDD.CHARGING.PERIODIC.TASK。 2022-03-07 20:43:04.727 5103-5103/? I/MDDTaskScheduler:MDDTaskScheduler$Runner.onRunTask():37 任务 mdd_periodical_task_MDD.CHARGING.PERIODIC.TASK 已启动 2022-03-07 20:43:04.734 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 任务:mdd_periodical_task_MDD.CHARGING.PERIODIC.TASK 成功。 2022-03-07 20:43:04.945 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136125):avc:拒绝{getattr} for path =“/ proc/fb”dev =“proc”ino = 4026531964 scontext = u:r:shell:s0 tcontext = u: object_r:proc:s0 tclass=文件许可=0 2022-03-07 20:43:04.945 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136126):avc:拒绝{getattr} for path =“/ proc/keys”dev =“proc”ino = 4026532156 scontext = u:r:shell:s0 tcontext = u: object_r:proc_keys:s0 tclass=文件许可=0 2022-03-07 20:43:04.945 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136127):avc:拒绝{getattr} for path =“/ proc/kmsg”dev =“proc”ino = 4026532061 scontext = u:r:shell:s0 tcontext = u: object_r:proc_kmsg:s0 tclass=文件许可=0 2022-03-07 20:43:04.945 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136128):avc:拒绝{getattr} for path =“/ proc/misc”dev =“proc”ino = 4026531965 scontext = u:r:shell:s0 tcontext = u: object_r:proc_misc:s0 tclass=文件许可=0 2022-03-07 20:43:04.945 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136129):avc:拒绝{getattr} for path =“/ proc/iomem”dev =“proc”ino = 4026532140 scontext = u:r:shell:s0 tcontext = u: object_r:proc_iomem:s0 tclass=文件许可=0 2022-03-07 20:43:05.111 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl $TaskRunnerJobService.onStartJob():204 onStartJob():mdd_periodical_task_MDD.MAINTENANCE.PERIODIC.GCM.TASK。 2022-03-07 20:43:05.111 5103-5103/? I/MDDTaskScheduler:MDDTaskScheduler$Runner.onRunTask():37 任务 mdd_periodical_task_MDD.MAINTENANCE.PERIODIC.GCM.TASK 已启动 2022-03-07 20:43:05.152 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 任务:mdd_periodical_task_MDD.MAINTENANCE.PERIODIC.GCM.TASK 成功。 2022-03-07 20:43:05.308 1097-2576/? I/slpi:ALS_OC LUX:3.90,比例:0.99,CH0:32,CH1:38,AT:198.80,AG:138 2022-03-07 20:43:05.369 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl $TaskRunnerJobService.onStartJob():204 onStartJob():mdd_periodical_task_MDD.CELLULAR.CHARGING.PERIODIC.TASK。 2022-03-07 20:43:05.370 5103-5103/? I/MDDTaskScheduler:MDDTaskScheduler$Runner.onRunTask():37 任务 mdd_periodical_task_MDD.CELLULAR.CHARGING.PERIODIC.TASK 已启动 2022-03-07 20:43:05.376 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 任务:mdd_periodical_task_MDD.CELLULAR.CHARGING.PERIODIC.TASK 成功。 2022-03-07 20:43:05.608 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl $TaskRunnerJobService.onStartJob():204 onStartJob():mdd_periodical_task_MDD.WIFI.CHARGING.PERIODIC.TASK。 2022-03-07 20:43:05.609 5103-5103/? I/MDDTaskScheduler:MDDTaskScheduler$Runner.onRunTask():37 任务 mdd_periodical_task_MDD.WIFI.CHARGING.PERIODIC.TASK 已启动 2022-03-07 20:43:05.614 5103-5103/? I/JobSchedulerImpl:JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 任务:mdd_periodical_task_MDD.WIFI.CHARGING.PERIODIC.TASK 成功。 2022-03-07 20:43:05.878 1097-28719/? E /传感器-hal:handle_sns_client_event:62,mot_disprot_event:现在= 79053277432287 ts = 79053059708105,类型= 0,状态= 3 2022-03-07 20:43:05.878 1097-28719/? E /传感器-hal:handle_sns_client_event:62,mot_disprot_event:现在= 79053278458433 ts = 79053263942480,类型= 16,状态= 3 2022-03-07 20:43:05.896 1097-2576/? I/slpi:ALS_OC LUX:4.70,比例:0.99,CH0:37,CH1:38,AT:198.80,AG:138 2022-03-07 20:43:06.005 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136165):avc:拒绝{getattr} for path =“/ proc/fb”dev =“proc”ino = 4026531964 scontext = u:r:shell:s0 tcontext = u: object_r:proc:s0 tclass=文件许可=0 2022-03-07 20:43:06.005 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136166):avc:拒绝{ getattr } for path =“/ proc/keys”dev =“proc”ino = 4026532156 scontext = u:r:shell:s0 tcontext = u: object_r:proc_keys:s0 tclass=文件许可=0 2022-03-07 20:43:06.005 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136167):avc:拒绝{getattr} for path =“/ proc/kmsg”dev =“proc”ino = 4026532061 scontext = u:r:shell:s0 tcontext = u: object_r:proc_kmsg:s0 tclass=文件许可=0 2022-03-07 20:43:06.005 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136168):avc:拒绝{getattr} for path =“/ proc/misc”dev =“proc”ino = 4026531965 scontext = u:r:shell:s0 tcontext = u: object_r:proc_misc:s0 tclass=文件许可=0 2022-03-07 20:43:06.005 22132-22132/? W/DetectPable:类型= 1400审核(0.0:136169):avc:拒绝{getattr} for path =“/ proc/iomem”dev =“proc”ino = 4026532140 scontext = u:r:shell:s0 tcontext = u: object_r:proc_iomem:s0 tclass=文件许可=0 2022-03-07 20:43:06.097 2108-2108/? E/AudioService.OrientationHelper:未知的设备旋转
I'm looking for some help. I took an android programming class and we need to build an app that takes sensor data (accelerometer, gyroscope, and magnetic field) into an array, and display the values. Unfortunately, I only know basic Java and I feel a bit stuck with some of the logic.
I started my app by displaying the real time values of the sensors. I got that working, but it's too noisy and not accurate. So I am trying to store the values generated from the sensor to an array, then display those values in a TextView. Now when I run the app, it only crashes. I am not sure what I am missing, but it is probably some Java logic.
In total, I have the UI set up properly. I have the MainActivity.java, and separate java classes to collect the sensor data set up with getters and setters.
The MainActivity code:
package com.example.servicesassignmentone;
import androidx.appcompat.app.AppCompatActivity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements SensorEventListener{
private Button myButton;
Handler myHandler = new Handler();
private TextView accelerometerX, accelerometerY, accelerometerZ;
private SensorManager sensorManager;
private Sensor sensorAccelerometer;
private boolean sensorAccelerometerSet = false;
private List<Accelerometer> accelerometerListValues = new ArrayList<Accelerometer>();
private TextView gyroscopeX, gyroscopeY, gyroscopeZ;
private Sensor sensorGyroscope;
private boolean sensorGyroscopeSet = false;
private List<Gyroscope> gyroscopeLastValues = new ArrayList<Gyroscope>();
private TextView magFieldX, magFieldY, magFieldZ;
private Sensor sensorMagField;
private boolean sensorMagFieldSet = false;
private List<MagField> magFieldLastValues = new ArrayList<MagField>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// button and UI initialization
myButton = (Button) findViewById(R.id.myButton);
//Accelerometer
accelerometerX = (TextView) findViewById(R.id.textViewAccX);
accelerometerY = (TextView) findViewById(R.id.textViewAccY);
accelerometerZ = (TextView) findViewById(R.id.textViewAccZ);
//Gyroscope
gyroscopeX = (TextView) findViewById(R.id.textViewGyroX);
gyroscopeY = (TextView) findViewById(R.id.textViewGyroY);
gyroscopeZ = (TextView) findViewById(R.id.textViewGyroZ);
//Magnetic Field
magFieldX = (TextView) findViewById(R.id.textViewMagX);
magFieldY = (TextView) findViewById(R.id.textViewMagY);
magFieldZ = (TextView) findViewById(R.id.textViewMagZ);
// initializing the sensor manager
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
// initializing the different sensors
sensorAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sensorGyroscope = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
sensorMagField = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.myButton:
sensorManager.registerListener((SensorEventListener) MainActivity.this, sensorAccelerometer, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) MainActivity.this, sensorGyroscope, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) MainActivity.this, sensorMagField, SensorManager.SENSOR_DELAY_FASTEST);
break;
}
}
});
}
@Override
protected void onResume() {
super.onResume();
sensorAccelerometerSet = false;
sensorGyroscopeSet = false;
sensorMagFieldSet = false;
sensorManager.registerListener((SensorEventListener) this, sensorAccelerometer, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) this, sensorGyroscope, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener((SensorEventListener) this, sensorMagField, SensorManager.SENSOR_DELAY_FASTEST);
}
@Override
protected void onPause() {
super.onPause();
sensorManager.unregisterListener((SensorEventListener) this);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
//Using the arraylist
Float accelerValuesX, accelerValuesY, accelerValuesZ;
Float gyroValuesX, gyroValuesY, gyroValuesZ;
Float magValuesX, magValuesY, magValuesZ;
//if (accelerometerListValues.size() >= 500 && gyroscopeLastValues.size() >= 500 && magFieldLastValues.size() >= 500) {
//}
if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
accelerValuesX = sensorEvent.values[0];
accelerValuesY = sensorEvent.values[1];
accelerValuesZ = sensorEvent.values[2];
accelerometerListValues.add(new Accelerometer(accelerValuesX, accelerValuesY, accelerValuesZ));
for (int i = 0; i < accelerometerListValues.size(); i++) {
Accelerometer output = accelerometerListValues.get(i);
accelerometerX.setText((CharSequence) output);
}
}
if (sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
gyroValuesX = sensorEvent.values[0];
gyroValuesY = sensorEvent.values[1];
gyroValuesZ = sensorEvent.values[2];
gyroscopeLastValues.add(new Gyroscope(gyroValuesX, gyroValuesY, gyroValuesZ));
for (int i = 0; i < gyroscopeLastValues.size(); i++) {
Gyroscope output = gyroscopeLastValues.get(i);
gyroscopeX.setText((CharSequence) output);
}
}
if (sensorEvent.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
magValuesX = sensorEvent.values[0];
magValuesY = sensorEvent.values[1];
magValuesZ = sensorEvent.values[2];
magFieldLastValues.add(new MagField(magValuesX, magValuesY, magValuesZ));
for (int i = 0; i < magFieldLastValues.size(); i++) {
MagField output = magFieldLastValues.get(i);
magFieldX.setText((CharSequence) output);
}
}
The debugging log is very long:
--------- beginning of crash
2022-03-07 20:42:59.962 28780-28780/com.example.servicesassignmentone E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.servicesassignmentone, PID: 28780
java.lang.ClassCastException: com.example.servicesassignmentone.Accelerometer cannot be cast to java.lang.CharSequence
at com.example.servicesassignmentone.MainActivity.onSensorChanged(MainActivity.java:120)
at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:900)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:342)
at android.os.Looper.loop(Looper.java:197)
at android.app.ActivityThread.main(ActivityThread.java:7803)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
2022-03-07 20:42:59.970 2108-28828/? I/DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
2022-03-07 20:42:59.971 2108-3891/? W/ActivityTaskManager: Force finishing activity com.example.servicesassignmentone/.MainActivity
2022-03-07 20:43:00.011 2108-2282/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2022-03-07 20:43:00.012 2108-2282/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2022-03-07 20:43:00.018 28780-28780/com.example.servicesassignmentone I/Process: Sending signal. PID: 28780 SIG: 9
2022-03-07 20:43:00.030 5605-5638/? W/DynamicVolume-DynamicVolumeService: onForegroundActivitiesChanged, but feature not opened, ignore!
2022-03-07 20:43:00.059 1106-1218/? E/qdmetadata: paramType 2048 not supported
2022-03-07 20:43:00.068 2108-9083/? I/ActivityManager: Process com.example.servicesassignmentone (pid 28780) has died: prcp TOP
2022-03-07 20:43:00.069 2108-3891/? I/WindowManager: WIN DEATH: Window{6c0ef4 u0 com.example.servicesassignmentone/com.example.servicesassignmentone.MainActivity}
2022-03-07 20:43:00.069 2108-3891/? W/InputDispatcher: Attempted to unregister already unregistered input channel '6c0ef4 com.example.servicesassignmentone/com.example.servicesassignmentone.MainActivity (server)'
2022-03-07 20:43:00.069 1097-1097/? I/sensors-hal: batch:242, android.sensor.accelerometer/11, period=200000000, max_latency=0
2022-03-07 20:43:00.069 1097-1097/? I/sensors-hal: set_config:63, sample_period_ns is adjusted to 200000000 based on min/max delay_ns
2022-03-07 20:43:00.069 1097-1097/? I/sensors-hal: batch:251, android.sensor.accelerometer/11, period=200000000, max_latency=0 request completed
2022-03-07 20:43:00.071 1097-1097/? I/sensors-hal: activate:209, android.sensor.magnetic_field/21 en=0
2022-03-07 20:43:00.075 1097-28701/? I/sensors-hal: ssc_conn_resp_cb:654, resp_value = 0
2022-03-07 20:43:00.076 1097-1097/? E/Diag_Lib: diag: Diag_LSM_DeInit done for pid: 1097
2022-03-07 20:43:00.076 1097-1097/? I/sensors-hal: activate:220, android.sensor.magnetic_field/21 en=0 completed
2022-03-07 20:43:00.076 1097-1097/? I/sensors-hal: activate:209, android.sensor.gyroscope/41 en=0
2022-03-07 20:43:00.078 1195-1219/? E/adsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:596:Error 0xffffffff: apps_std getenv failed: ADSP_LIBRARY_PATH Unknown error -1
2022-03-07 20:43:00.079 1195-1219/? I/adsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:777: Successfully opened file /mnt/vendor/persist/sensors/registry/temp.json
2022-03-07 20:43:00.082 1097-1097/? E/Diag_Lib: diag: Diag_LSM_DeInit done for pid: 1097
2022-03-07 20:43:00.083 1195-1219/? E/adsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:596:Error 0xffffffff: apps_std getenv failed: ADSP_LIBRARY_PATH Unknown error -1
2022-03-07 20:43:00.083 1195-1219/? I/adsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:777: Successfully opened file /mnt/vendor/persist/sensors/registry/temp.json
2022-03-07 20:43:00.083 1097-1097/? E/Diag_Lib: diag: Diag_LSM_DeInit done for pid: 1097
2022-03-07 20:43:00.083 1097-1097/? I/sensors-hal: activate:220, android.sensor.gyroscope/41 en=0 completed
2022-03-07 20:43:00.088 1001-1001/? I/Zygote: Process 28780 exited due to signal 9 (Killed)
2022-03-07 20:43:00.099 2108-2315/? I/libprocessgroup: Successfully killed process cgroup uid 10298 pid 28780 in 29ms
2022-03-07 20:43:00.109 3818-3838/? I/ndroid.systemu: NativeAlloc concurrent copying GC freed 13956(730KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 8443KB/16MB, paused 76us total 105.730ms
2022-03-07 20:43:00.122 3818-3844/? W/System: A resource failed to call release.
2022-03-07 20:43:00.131 2108-2259/? W/ActivityManager: setHasOverlayUi called on unknown pid: 28780
2022-03-07 20:43:00.145 2108-2260/? I/WindowManager: SURFACE show Surface(name=com.android.systemui.ImageWallpaper)/@0x704dd96 on display:0
2022-03-07 20:43:00.146 2108-2259/? E/SystemServiceRegistry: No service published for: payjoy_access_service
android.os.ServiceManager$ServiceNotFoundException: No service published for: payjoy_access_service
at android.os.ServiceManager.getServiceOrThrow(ServiceManager.java:153)
at android.app.SystemServiceRegistry$126.createService(SystemServiceRegistry.java:1694)
at android.app.SystemServiceRegistry$StaticServiceFetcher.getService(SystemServiceRegistry.java:1919)
at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:1517)
at android.app.ContextImpl.getSystemService(ContextImpl.java:1938)
at com.android.server.wm.ActivityStack.shouldSendPayJoyBroadcast(ActivityStack.java:3644)
at com.android.server.wm.ActivityStack.access$000(ActivityStack.java:188)
at com.android.server.wm.ActivityStack$ActivityStackHandler.handleMessage(ActivityStack.java:316)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:250)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:44)
2022-03-07 20:43:00.146 2108-2259/? E/SystemServiceRegistry: Manager wrapper not available: payjoy_access_service
2022-03-07 20:43:00.148 2108-2260/? I/WindowManager: SURFACE show Surface(name=com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher)/@0x43cd0d3 on display:0
2022-03-07 20:43:00.148 2108-2260/? I/WindowManager: SURFACE show Surface(name=com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher)/@0xbb76410 on display:0
2022-03-07 20:43:00.157 5263-5263/? I/GsaVoiceInteractionSrv: Handling ACTION_START_HOTWORD
2022-03-07 20:43:00.160 1106-1218/? E/qdmetadata: paramType 2048 not supported
2022-03-07 20:43:00.160 1106-1218/? E/qdmetadata: paramType 2048 not supported
2022-03-07 20:43:00.161 5263-5933/? I/GsaVoiceInteractionSrv: disregardVoiceMatch: false
2022-03-07 20:43:00.162 5263-5933/? I/GsaVoiceInteractionSrv: Cannot start hotword, hotword has been explicitly disabled.
2022-03-07 20:43:00.167 1111-1111/? I/QTI PowerHAL: Power setMode: 5 to: 0
2022-03-07 20:43:00.168 5103-5103/? I/GoogleInputMethodService: GoogleInputMethodService.onFinishInput():3210
2022-03-07 20:43:00.175 5103-5103/? I/GoogleInputMethodService: GoogleInputMethodService.updateDeviceLockedStatus():2099 checkRepeatedly = false, unlocked = true
2022-03-07 20:43:00.175 5103-5103/? I/GoogleInputMethodService: GoogleInputMethodService.onStartInput():1907 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0 initialSelStart=-1 initialSelEnd=-1 initialCapsMode=0x0 hintText=null label=null packageName=com.motorola.launcher3 fieldId=-1 fieldName=null extras=null}, false)
2022-03-07 20:43:00.177 5103-5103/? I/GoogleInputMethodService: GoogleInputMethodService.updateDeviceLockedStatus():2099 checkRepeatedly = true, unlocked = true
2022-03-07 20:43:00.263 5537-5556/? D/AssistReceiver: call: lightWakeup | null | null
2022-03-07 20:43:00.284 1106-1218/? E/qdmetadata: paramType 2048 not supported
2022-03-07 20:43:00.476 2108-2259/? W/ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{c3cd9a0 u0 com.example.servicesassignmentone/.MainActivity t-1 f}}
2022-03-07 20:43:00.484 4941-4941/? D/GameMode: isScreenUnlocked: true
2022-03-07 20:43:00.486 4941-4941/? D/GameMode: exiting game mode
2022-03-07 20:43:00.491 4941-4941/? D/GameMode: reset : false
2022-03-07 20:43:00.491 4941-4941/? D/GameMode: reset:
2022-03-07 20:43:00.491 4941-4941/? D/GameMode: isFeatureSupported: false
2022-03-07 20:43:00.495 4941-7481/? D/MFL: getFreeFormPackages: is blank
2022-03-07 20:43:00.496 4941-7481/? D/MFL: getDensityIndependentPixel: smallest width = 411
2022-03-07 20:43:00.497 4941-7481/? D/MFL: getLaunchRect: margin = 0
2022-03-07 20:43:00.708 22132-22132/? W/DetectPable: type=1400 audit(0.0:135965): avc: denied { getattr } for path="/proc/fb" dev="proc" ino=4026531964 scontext=u:r:shell:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=0
2022-03-07 20:43:00.708 22132-22132/? W/DetectPable: type=1400 audit(0.0:135966): avc: denied { getattr } for path="/proc/keys" dev="proc" ino=4026532156 scontext=u:r:shell:s0 tcontext=u:object_r:proc_keys:s0 tclass=file permissive=0
2022-03-07 20:43:00.708 22132-22132/? W/DetectPable: type=1400 audit(0.0:135967): avc: denied { getattr } for path="/proc/kmsg" dev="proc" ino=4026532061 scontext=u:r:shell:s0 tcontext=u:object_r:proc_kmsg:s0 tclass=file permissive=0
2022-03-07 20:43:00.708 22132-22132/? W/DetectPable: type=1400 audit(0.0:135968): avc: denied { getattr } for path="/proc/misc" dev="proc" ino=4026531965 scontext=u:r:shell:s0 tcontext=u:object_r:proc_misc:s0 tclass=file permissive=0
2022-03-07 20:43:00.708 22132-22132/? W/DetectPable: type=1400 audit(0.0:135969): avc: denied { getattr } for path="/proc/iomem" dev="proc" ino=4026532140 scontext=u:r:shell:s0 tcontext=u:object_r:proc_iomem:s0 tclass=file permissive=0
2022-03-07 20:43:01.768 22132-22132/? W/DetectPable: type=1400 audit(0.0:136005): avc: denied { getattr } for path="/proc/fb" dev="proc" ino=4026531964 scontext=u:r:shell:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=0
2022-03-07 20:43:01.768 22132-22132/? W/DetectPable: type=1400 audit(0.0:136006): avc: denied { getattr } for path="/proc/keys" dev="proc" ino=4026532156 scontext=u:r:shell:s0 tcontext=u:object_r:proc_keys:s0 tclass=file permissive=0
2022-03-07 20:43:01.768 22132-22132/? W/DetectPable: type=1400 audit(0.0:136007): avc: denied { getattr } for path="/proc/kmsg" dev="proc" ino=4026532061 scontext=u:r:shell:s0 tcontext=u:object_r:proc_kmsg:s0 tclass=file permissive=0
2022-03-07 20:43:01.773 1112-1137/? I/[email protected]: uevent triggered for sensor: msm_therm
2022-03-07 20:43:01.768 22132-22132/? W/DetectPable: type=1400 audit(0.0:136008): avc: denied { getattr } for path="/proc/misc" dev="proc" ino=4026531965 scontext=u:r:shell:s0 tcontext=u:object_r:proc_misc:s0 tclass=file permissive=0
2022-03-07 20:43:01.771 22132-22132/? W/DetectPable: type=1400 audit(0.0:136009): avc: denied { getattr } for path="/proc/iomem" dev="proc" ino=4026532140 scontext=u:r:shell:s0 tcontext=u:object_r:proc_iomem:s0 tclass=file permissive=0
2022-03-07 20:43:02.828 22132-22132/? W/DetectPable: type=1400 audit(0.0:136045): avc: denied { getattr } for path="/proc/fb" dev="proc" ino=4026531964 scontext=u:r:shell:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=0
2022-03-07 20:43:02.828 22132-22132/? W/DetectPable: type=1400 audit(0.0:136046): avc: denied { getattr } for path="/proc/keys" dev="proc" ino=4026532156 scontext=u:r:shell:s0 tcontext=u:object_r:proc_keys:s0 tclass=file permissive=0
2022-03-07 20:43:02.828 22132-22132/? W/DetectPable: type=1400 audit(0.0:136047): avc: denied { getattr } for path="/proc/kmsg" dev="proc" ino=4026532061 scontext=u:r:shell:s0 tcontext=u:object_r:proc_kmsg:s0 tclass=file permissive=0
2022-03-07 20:43:02.828 22132-22132/? W/DetectPable: type=1400 audit(0.0:136048): avc: denied { getattr } for path="/proc/misc" dev="proc" ino=4026531965 scontext=u:r:shell:s0 tcontext=u:object_r:proc_misc:s0 tclass=file permissive=0
2022-03-07 20:43:02.828 22132-22132/? W/DetectPable: type=1400 audit(0.0:136049): avc: denied { getattr } for path="/proc/iomem" dev="proc" ino=4026532140 scontext=u:r:shell:s0 tcontext=u:object_r:proc_iomem:s0 tclass=file permissive=0
2022-03-07 20:43:02.954 1097-2576/? I/slpi: ALS_OC LUX:6.20,SCALE:0.99, CH0:50, CH1:54, aT:198.80, aG:138
2022-03-07 20:43:03.142 5966-6209/? I/WorkerManager: dispose()
2022-03-07 20:43:03.150 1097-2576/? I/slpi: ALS_OC LUX:5.10,SCALE:0.99, CH0:40, CH1:39, aT:198.80, aG:138
2022-03-07 20:43:03.346 2108-2574/? D/BatteryService: uevent={POWER_SUPPLY_DP_DM=0, POWER_SUPPLY_TEMP_HOT=0, POWER_SUPPLY_VOLTAGE_QNOVO=-22, POWER_SUPPLY_VOLTAGE_NOW=4373493, POWER_SUPPLY_SW_JEITA_ENABLED=0, POWER_SUPPLY_CHARGE_CONTROL_LIMIT_MAX=8, POWER_SUPPLY_RECHARGE_SOC=99, POWER_SUPPLY_HEALTH=Good, POWER_SUPPLY_TECHNOLOGY=Li-ion, POWER_SUPPLY_CHARGER_TEMP_MAX=800, POWER_SUPPLY_CHARGE_FULL_DESIGN=4100000, POWER_SUPPLY_FCC_STEPPER_ENABLE=0, SEQNUM=20602, POWER_SUPPLY_INPUT_CURRENT_LIMITED=0, POWER_SUPPLY_CHARGE_CONTROL_LIMIT=0, POWER_SUPPLY_STATUS=Full, POWER_SUPPLY_CURRENT_MAX=0, POWER_SUPPLY_CYCLE_COUNT=0, POWER_SUPPLY_CHARGE_TERM_CURRENT=-102, POWER_SUPPLY_CAPACITY=100, DEVPATH=/devices/platform/soc/1c40000.qcom,spmi/spmi-0/spmi0-02/1c40000.qcom,spmi:qcom,pmi632@2:qcom,qpnp-smb5-mmi/power_supply/battery, POWER_SUPPLY_CHARGE_DONE=1, POWER_SUPPLY_CHARGE_TYPE=N/A, POWER_SUPPLY_CHARGER_TEMP=290, POWER_SUPPLY_CHARGE_RATE=Normal, POWER_SUPPLY_CURRENT_QNOVO=-22, POWER_SUPPLY_CURRENT_NOW=0, POWER_SUPPLY_PRESENT=1, POWER_SUPPLY_PARALLEL_DISABLE=0, POWER_SUPPLY_CHARGE_FULL=4104000, POWER_SUPPLY_CONSTANT_CHARGE_CURRENT=0, SUBSYSTEM=power_supply, POWER_SUPPLY_SET_SHIP_MODE=0, POWER_SUPPLY_TEMP=267, ACTION=change, POWER_SUPPLY_RERUN_AICL=0, POWER_SUPPLY_NAME=battery, POWER_SUPPLY_VOLTAGE_MAX=-22, POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3600000, POWER_SUPPLY_CHARGE_COUNTER=4104000, POWER_SUPPLY_STEP_CHARGING_ENABLED=0, POWER_SUPPLY_DIE_HEALTH=Cool, POWER_SUPPLY_INPUT_SUSPEND=0}
2022-03-07 20:43:03.885 22132-22132/? W/DetectPable: type=1400 audit(0.0:136085): avc: denied { getattr } for path="/proc/fb" dev="proc" ino=4026531964 scontext=u:r:shell:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=0
2022-03-07 20:43:03.885 22132-22132/? W/DetectPable: type=1400 audit(0.0:136086): avc: denied { getattr } for path="/proc/keys" dev="proc" ino=4026532156 scontext=u:r:shell:s0 tcontext=u:object_r:proc_keys:s0 tclass=file permissive=0
2022-03-07 20:43:03.885 22132-22132/? W/DetectPable: type=1400 audit(0.0:136087): avc: denied { getattr } for path="/proc/kmsg" dev="proc" ino=4026532061 scontext=u:r:shell:s0 tcontext=u:object_r:proc_kmsg:s0 tclass=file permissive=0
2022-03-07 20:43:03.885 22132-22132/? W/DetectPable: type=1400 audit(0.0:136088): avc: denied { getattr } for path="/proc/misc" dev="proc" ino=4026531965 scontext=u:r:shell:s0 tcontext=u:object_r:proc_misc:s0 tclass=file permissive=0
2022-03-07 20:43:03.885 22132-22132/? W/DetectPable: type=1400 audit(0.0:136089): avc: denied { getattr } for path="/proc/iomem" dev="proc" ino=4026532140 scontext=u:r:shell:s0 tcontext=u:object_r:proc_iomem:s0 tclass=file permissive=0
2022-03-07 20:43:04.696 4875-28832/? I/Authzen: [DeviceStateSyncManager] The server is in sync with current state. Nothing to do
2022-03-07 20:43:04.726 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService.onStartJob():204 onStartJob(): mdd_periodical_task_MDD.CHARGING.PERIODIC.TASK.
2022-03-07 20:43:04.727 5103-5103/? I/MDDTaskScheduler: MDDTaskScheduler$Runner.onRunTask():37 task mdd_periodical_task_MDD.CHARGING.PERIODIC.TASK started
2022-03-07 20:43:04.734 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 Task: mdd_periodical_task_MDD.CHARGING.PERIODIC.TASK successes.
2022-03-07 20:43:04.945 22132-22132/? W/DetectPable: type=1400 audit(0.0:136125): avc: denied { getattr } for path="/proc/fb" dev="proc" ino=4026531964 scontext=u:r:shell:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=0
2022-03-07 20:43:04.945 22132-22132/? W/DetectPable: type=1400 audit(0.0:136126): avc: denied { getattr } for path="/proc/keys" dev="proc" ino=4026532156 scontext=u:r:shell:s0 tcontext=u:object_r:proc_keys:s0 tclass=file permissive=0
2022-03-07 20:43:04.945 22132-22132/? W/DetectPable: type=1400 audit(0.0:136127): avc: denied { getattr } for path="/proc/kmsg" dev="proc" ino=4026532061 scontext=u:r:shell:s0 tcontext=u:object_r:proc_kmsg:s0 tclass=file permissive=0
2022-03-07 20:43:04.945 22132-22132/? W/DetectPable: type=1400 audit(0.0:136128): avc: denied { getattr } for path="/proc/misc" dev="proc" ino=4026531965 scontext=u:r:shell:s0 tcontext=u:object_r:proc_misc:s0 tclass=file permissive=0
2022-03-07 20:43:04.945 22132-22132/? W/DetectPable: type=1400 audit(0.0:136129): avc: denied { getattr } for path="/proc/iomem" dev="proc" ino=4026532140 scontext=u:r:shell:s0 tcontext=u:object_r:proc_iomem:s0 tclass=file permissive=0
2022-03-07 20:43:05.111 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService.onStartJob():204 onStartJob(): mdd_periodical_task_MDD.MAINTENANCE.PERIODIC.GCM.TASK.
2022-03-07 20:43:05.111 5103-5103/? I/MDDTaskScheduler: MDDTaskScheduler$Runner.onRunTask():37 task mdd_periodical_task_MDD.MAINTENANCE.PERIODIC.GCM.TASK started
2022-03-07 20:43:05.152 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 Task: mdd_periodical_task_MDD.MAINTENANCE.PERIODIC.GCM.TASK successes.
2022-03-07 20:43:05.308 1097-2576/? I/slpi: ALS_OC LUX:3.90,SCALE:0.99, CH0:32, CH1:38, aT:198.80, aG:138
2022-03-07 20:43:05.369 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService.onStartJob():204 onStartJob(): mdd_periodical_task_MDD.CELLULAR.CHARGING.PERIODIC.TASK.
2022-03-07 20:43:05.370 5103-5103/? I/MDDTaskScheduler: MDDTaskScheduler$Runner.onRunTask():37 task mdd_periodical_task_MDD.CELLULAR.CHARGING.PERIODIC.TASK started
2022-03-07 20:43:05.376 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 Task: mdd_periodical_task_MDD.CELLULAR.CHARGING.PERIODIC.TASK successes.
2022-03-07 20:43:05.608 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService.onStartJob():204 onStartJob(): mdd_periodical_task_MDD.WIFI.CHARGING.PERIODIC.TASK.
2022-03-07 20:43:05.609 5103-5103/? I/MDDTaskScheduler: MDDTaskScheduler$Runner.onRunTask():37 task mdd_periodical_task_MDD.WIFI.CHARGING.PERIODIC.TASK started
2022-03-07 20:43:05.614 5103-5103/? I/JobSchedulerImpl: JobSchedulerImpl$TaskRunnerJobService$Callback.onSuccess():380 Task: mdd_periodical_task_MDD.WIFI.CHARGING.PERIODIC.TASK successes.
2022-03-07 20:43:05.878 1097-28719/? E/sensors-hal: handle_sns_client_event:62, mot_disprot_event: now=79053277432287 ts=79053059708105, type=0, status=3
2022-03-07 20:43:05.878 1097-28719/? E/sensors-hal: handle_sns_client_event:62, mot_disprot_event: now=79053278458433 ts=79053263942480, type=16, status=3
2022-03-07 20:43:05.896 1097-2576/? I/slpi: ALS_OC LUX:4.70,SCALE:0.99, CH0:37, CH1:38, aT:198.80, aG:138
2022-03-07 20:43:06.005 22132-22132/? W/DetectPable: type=1400 audit(0.0:136165): avc: denied { getattr } for path="/proc/fb" dev="proc" ino=4026531964 scontext=u:r:shell:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=0
2022-03-07 20:43:06.005 22132-22132/? W/DetectPable: type=1400 audit(0.0:136166): avc: denied { getattr } for path="/proc/keys" dev="proc" ino=4026532156 scontext=u:r:shell:s0 tcontext=u:object_r:proc_keys:s0 tclass=file permissive=0
2022-03-07 20:43:06.005 22132-22132/? W/DetectPable: type=1400 audit(0.0:136167): avc: denied { getattr } for path="/proc/kmsg" dev="proc" ino=4026532061 scontext=u:r:shell:s0 tcontext=u:object_r:proc_kmsg:s0 tclass=file permissive=0
2022-03-07 20:43:06.005 22132-22132/? W/DetectPable: type=1400 audit(0.0:136168): avc: denied { getattr } for path="/proc/misc" dev="proc" ino=4026531965 scontext=u:r:shell:s0 tcontext=u:object_r:proc_misc:s0 tclass=file permissive=0
2022-03-07 20:43:06.005 22132-22132/? W/DetectPable: type=1400 audit(0.0:136169): avc: denied { getattr } for path="/proc/iomem" dev="proc" ino=4026532140 scontext=u:r:shell:s0 tcontext=u:object_r:proc_iomem:s0 tclass=file permissive=0
2022-03-07 20:43:06.097 2108-2108/? E/AudioService.OrientationHelper: Unknown device rotation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您提供的调试日志来看,
问题发生在 MainActivity.java:120(第 120 行)
变量
output
是一个Accelerometer
,但您将其转换为字符序列
。我不知道 com.example.servicesassignmentone.Accelerometer 看起来如何,因为您没有显示代码,但我确信您可能有一种方法可以访问它的值。From the debug log you've provided
The problem happens at MainActivity.java:120 (Line 120)
Variable
output
is aAccelerometer
, but you are casting it to aCharSequence
. I have no idea howcom.example.servicesassignmentone.Accelerometer
looks like as you didn't show the code, but I am sure that there is probably a method for you to access it's value.