public class Speedo extends Activity {
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg != null) {
if (msg.what == MessageHandler.MSG_NOT_CONNECTED) {
textBluetoothStatus.setText("Not connected");
} else if (msg.what == MessageHandler.MSG_CONNECTING) {
textBluetoothStatus.setText("Connecting...");
} else if (msg.what == MessageHandler.MSG_CONNECTED) {
textBluetoothStatus.setText("Connected");
mDeviceConnector.sendAsciiMessage("TEST");
} else if (msg.what == MessageHandler.MSG_CONNECTION_FAILED) {
textBluetoothStatus.setText("Connection failed");
} else if (msg.what == MessageHandler.MSG_CONNECTION_LOST) {
textBluetoothStatus.setText("Connection lost");
} else if (msg.what == MessageHandler.MSG_LINE_READ) {
Log.i("msg", msg.toString());
cmd = msg.obj.toString();
cmd = cmd.trim();
textBluetooth.setText(cmd);
}
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
Scanner in = new Scanner(((TextView) findViewById(R.id.bluetooth)).getText() + "").useDelimiter("[^0-9]+");
int bluetoothSpeed = in.nextInt();
GPSspeed = Integer.parseInt(edittext.getText() + "");
textSpeed.setText(GPSspeed + " km/h");
speedometer.setSpeed(GPSspeed);
if (bluetoothSpeed < GPSspeed && (bluetoothSpeed != lastBluetoothSpeed || GPSspeed != lastGPSspeed || lastBluetoothTime + 120 <= System.currentTimeMillis() / 1000L)) {
lastBluetoothSpeed = bluetoothSpeed;
lastGPSspeed = Integer.parseInt(edittext.getText() + "");
lastBluetoothTime = System.currentTimeMillis() / 1000L;
if(!player.isPlaying()) {
player.start();
sendsms ();
}
wakeLock.acquire();
handler.postDelayed(runnable, 120000);
}
}
catch (NumberFormatException e) {
Snackbar.make(findViewById(android.R.id.content), "Number format error", Snackbar.LENGTH_LONG).show();
}
catch (NoSuchElementException e) {
Snackbar.make(findViewById(android.R.id.content), "Bluetooth format error", Snackbar.LENGTH_LONG).show();
}
}
});
alert.show();
}
});
private class MyLocationListener implements LocationListener {
Integer counter = 0;
public void onLocationChanged(Location loc) {
Log.i("GPS", "updated");
GPSspeed = speed.intValue();
textSpeed.setText(GPSspeed + " km/h");
speedometer.setSpeed(GPSspeed);
try {
Scanner in = new Scanner(cmd).useDelimiter("[^0-9]+");
bluetoothSpeed = in.nextInt();
if (GPSspeed > bluetoothSpeed && (bluetoothSpeed != lastBluetoothSpeed || GPSspeed != lastGPSspeed )) {
lastBluetoothSpeed = bluetoothSpeed;
lastGPSspeed = GPSspeed;
lastBluetoothTime = System.currentTimeMillis() / 1000L;
sendsms ();
//mDeviceConnector.sendAsciiMessage("1");
if(!player.isPlaying()) {
player.start();
}
// handler.postDelayed(runnable, 120000);
// wakeLock.acquire();
}
else if(bluetoothSpeed != lastBluetoothSpeed){
lastBluetoothSpeed = bluetoothSpeed;
sendsms ();
}
else if (lastBluetoothSpeed != -1 && GPSspeed >lastBluetoothSpeed && GPSspeed != lastGPSspeed ) {
lastBluetoothTime = System.currentTimeMillis() / 1000L;
sendsms ();
// mDeviceConnector.sendAsciiMessage("1");
if(!player.isPlaying()) {
player.start();
}
// handler.postDelayed(runnable, 120000);
// wakeLock.acquire();
}
else {
// mDeviceConnector.sendAsciiMessage("0");
}
} catch (Exception e) {
e.printStackTrace(); Log.e(getResources().getString(R.string.app_name),"your_error_exception",e);
}
mDeviceConnector.sendAsciiMessage(GPSspeed + "");
} else {
textSpeed.setText("0 km/h");
}
}
07-16 13:20:54.952 831-831/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver com.jakewharton.smsbarrage.transaction.EventReceiver: java.lang.SecurityException: Neither user 10051 nor current process has android.permission.WAKE_LOCK.
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2236)
at android.app.ActivityThread.access$1500(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.SecurityException: Neither user 10051 nor current process has android.permission.WAKE_LOCK.
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:288)
at android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:309)
at android.os.PowerManager$WakeLock.acquire(PowerManager.java:288)
at com.jakewharton.smsbarrage.transaction.EventReceiver.beginStartingService(EventReceiver.java:42)
at com.jakewharton.smsbarrage.transaction.EventReceiver.onReceive(EventReceiver.java:31)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2229)
at android.app.ActivityThread.access$1500(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
07-16 13:21:02.008 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 10220
07-16 13:21:02.008 123-205/? E/SocketStream: readFully was waiting for 677268 bytes, got 16192
07-16 13:21:02.008 123-205/? E/SocketStream: readFully was waiting for 661076 bytes, got 4248
07-16 13:21:19.996 436-919/? E/BinaryDictionaryGetter: Could not find a dictionary pack
07-16 13:21:19.996 436-919/? E/ActivityThread: Failed to find provider info for com.android.inputmethod.latin.dictionarypack
07-16 13:21:22.848 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 16192
07-16 13:21:22.860 123-205/? E/SocketStream: readFully was waiting for 671296 bytes, got 16192
07-16 13:21:29.916 436-985/? E/ActivityThread: Failed to find provider info for com.android.inputmethod.latin.dictionarypack
07-16 13:21:29.956 436-985/? E/BinaryDictionaryGetter: Could not find a dictionary pack
07-16 13:21:32.412 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 16192
07-16 13:21:32.424 123-205/? E/SocketStream: readFully was waiting for 671296 bytes, got 16192
07-16 13:39:36.892 1121-1121/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.toshiba.GpsBluetooth/com.example.toshiba.GpsBluetooth.Speedo}: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.Toolbar
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.example.toshiba.GpsBluetooth.Speedo.onCreate(Speedo.java:134)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.example.toshiba.GpsBluetooth.Speedo.onCreate(Speedo.java:134)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:692)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:67)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:298)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:229)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.example.toshiba.GpsBluetooth.Speedo.onCreate(Speedo.java:134)
at android.app.Activity.performCreatat android.app ctivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
07-16 13:39:37.160 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 16192
07-16 13:39:37.160 123-205/? E/SocketStream: readFully was waiting for 671296 bytes, got 16192
07-16 13:57:28.840 123-205/? E/SocketStream: readFully was waiting for 23616 bytes, got 16192
07-16 13:57:29.184 1196-1196/? E/AndroidRuntime: FATAL EXCEPTION: main
如有任何帮助,不胜感激。
您将获得SecurityException:用户10051和当前进程都没有Android.permission.wake_lock
。
如果您的目标API为23或更高,请确保添加运行时权限以及Android清单中的权限。
从Android6.0(API级别23)开始,用户在应用程序运行时授予应用程序权限,而不是在安装应用程序时授予权限。
代码 和logcat 06-03 16:59:26.570 972 0-9757/com.example.abhijitroy.superhero E/AndroidRuntime:致命异常:AsyncTask#1进程:com.example.abhijitroy.superhero,PID:9720 java.lang.RuntimeException:在Android.os.AsyncTask
我正在尝试将我的launcher活动更改为我刚刚使用twitter数字开发的身份验证活动,我已经在我的android和java代码中做了必要的调整,但注意到每次我尝试启动时应用程序都会崩溃,身份验证活动的名称是,在调试会话期间,我从我的android monitor控制台中观察到,这一行在com.close.close.aboutactivity.onCreate(aboutactivity.ja
这个想法是在警报开始时启动一个游戏。我已经在下面展示了manifest.xml。如果我犯了错误,请纠正我。因为我是Android的新手,所以我不太懂。PS:我已经搜索了其他类似的问题,并更正了很多其他错误,但问题依然存在。 这是我从一个教程(AndroidTimeActivity)得到的警报代码: 这是AlarmReceiver类: 这里是Manager类,当警报接收器接收到意图时,我要调用它:
我正在通过proj.android-studio编译一个新项目,使用:
我会在我的模拟器上得到谷歌地图。我按照上面的说明操作,当我运行应用程序时,会出现一条错误消息:不幸的是,DemoGoogleMapsV2已经停止。 我的AndroidManifest.xml: 我的activity_main.xml: my mainactivity.java: 日志错误: 09-04 17:43:51.170:E/trace(1477):打开跟踪文件时出错:没有这样的文件或目录(
我的申请已经停止了。项目将场景转换为作业列表的主要应用,但是,作业列表转换为练习列表,我得到了这些“不幸的应用程序已经停止了”。这是我的类。我也是致命的,除了在logcat。 ApplicationMain.java joblist.java ExpresseList.java AndroidManifest.xml