Ich habe den gleichen Code mit einer niedrigeren Version (9.4.0) auf dem Telefon arbeiten, aber aus irgendeinem Grund wird es nicht auf RPi3 arbeiten? Mein build.gradleAndroid Things - kann Awareness API nicht verwenden
compile 'com.google.android.gms:play-services:10.0.0'
provided 'com.google.android.things:androidthings:0.4-devpreview'
Die offensichtlichen Berechtigungen
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
Verfahren
private void getWeather() {
// Check for permission first
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
Log.e(TAG, "Fine Location Permission not yet granted");
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
} else {
System.out.println("else of getWeather()");
Log.i(TAG, "Fine Location permission already granted");
// Weather
Awareness.SnapshotApi.getWeather(mGoogleApiClient).setResultCallback(new ResultCallback<WeatherResult>() {
@Override
public void onResult(@NonNull WeatherResult weatherResult) {
if (!weatherResult.getStatus().isSuccess()) {
Log.e(TAG, "Could not detect weather info");
mWeatherTextView.setText("Could not detect weather info");
mWeatherTextView.setTextColor(Color.RED);
System.out.println("NO WEATHER INFO");
return;
}
System.out.println("WEATHER INFO REC'D");
Weather weather = weatherResult.getWeather();
mWeatherTextView.setText(weather.toString());
}
});
}
}
Die logcat
08-15 23:46:09.504 411-432/? I/WindowManager: Destroying surface Surface(name=Starting com.example.cartier.thingsaware) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.WindowStateAnimator.finishExit:565 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:491 com.android.server.wm.WindowAnimator.updateWindowsLocked:303 com.android.server.wm.WindowAnimator.animateLocked:704
08-15 23:46:09.594 411-1124/? I/WindowManager: Destroying surface Surface(name=com.android.iotlauncher/com.android.iotlauncher.IoTLauncher) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.AppWindowToken.notifyAppStopped:389 com.android.server.wm.WindowManagerService.notifyAppStopped:4456 com.android.server.am.ActivityStack.activityStoppedLocked:1252 com.android.server.am.ActivityManagerService.activityStopped:6902
08-15 23:46:11.780 411-479/? E/TaskPersister: File error accessing recents directory (directory doesn't exist?).
08-15 23:46:35.798 3687-3687/? I/System.out: else of getWeather()
08-15 23:46:35.798 3687-3687/? I/MainActivity: Fine Location permission already granted
Aus irgendeinem Grund ist es nach der Erlaubnis, mir zu sagen stoppt ist gewährt. Die App stürzt jedoch nicht ab, ich habe einen OnClickListener, der getWeather() aufruft, so dass ich wiederholt klicken kann, aber nie Snapshot-Daten bekomme. Ich bin mit der gleichen API-Schlüssel, die auf dem Handy funktioniert ...
Nach dem docs die Awareness API auf den AndroidThings unterstützt & Ich habe Projekte waren die Leute der Nähe & andere APIs in die verwendet haben Anspruch gesehen Liste. Hat jemand Erfolg mit der Awareness API auf AndroidThings gehabt?
Nach dem Update zu spielen Dienste 11.0.0 öffnet die App die sofort schließt & jetzt die logcat
08-17 18:13:28.510 3148-3148/? I/System.out: onCreate
08-17 18:13:28.615 410-432/? I/ActivityManager: Displayed com.example.cartier.thingsaware/.MainActivity: +1s45ms
08-17 18:13:28.665 410-525/? I/WindowManager: Destroying surface Surface(name=com.android.iotlauncher/com.android.iotlauncher.IoTLauncher) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.AppWindowToken.notifyAppStopped:389 com.android.server.wm.WindowManagerService.notifyAppStopped:4456 com.android.server.am.ActivityStack.activityStoppedLocked:1252 com.android.server.am.ActivityManagerService.activityStopped:6902
08-17 18:13:28.881 410-432/? I/WindowManager: Destroying surface Surface(name=Starting com.example.cartier.thingsaware) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.WindowStateAnimator.finishExit:565 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:491 com.android.server.wm.WindowAnimator.updateWindowsLocked:303 com.android.server.wm.WindowAnimator.animateLocked:704
08-17 18:13:28.990 3148-3148/? I/Process: Sending signal. PID: 3148 SIG: 9
08-17 18:13:29.047 410-929/? I/ActivityManager: Process com.example.cartier.thingsaware (pid 3148) has died
08-17 18:13:29.047 410-525/? I/WindowManager: WIN DEATH: Window{9cbd0a u0 com.example.cartier.thingsaware/com.example.cartier.thingsaware.MainActivity}
08-17 18:13:29.048 410-525/? I/WindowManager: Destroying surface Surface(name=com.example.cartier.thingsaware/com.example.cartier.thingsaware.MainActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.removeLocked:1449 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2478 com.android.server.wm.WindowManagerService.removeWindowLocked:2436 com.android.server.wm.WindowState$DeathRecipient.binderDied:1780 android.os.BinderProxy.sendDeathNotice:688 <bottom of call stack>
08-17 18:13:29.083 638-638/? I/AndroidThingsLauncher: Peripheral I/O ports
08-17 18:13:29.083 638-638/? I/AndroidThingsLauncher: GPIO
Haben Sie die neueste Version von AndroidThings ausprobiert? '0.5.0' mit Play Services' 11' https://developer.android.com/things/preview/releases.html – Blundell
Danke @Blundell. Versucht, 0.5.0 mehrmals zu blinken, aber kein Glück damit. Befolgen Sie die Anweisungen von ThingsConsole: Produkt erstellen (bestimmte Ich habe die richtige SOM & links 32MB OEM-Standard)> config product> Gerätebild erstellen (mit leerem Bundle)> download & flash, aber jedes Mal, wenn der Bildschirm leer ist. Hast du etwas Besonderes gemacht, um deinen RPi3-Build zu erstellen? – JC23