1

我有相同的代碼與較低版本(9.4.0)在手機上工作,但由於某種原因,它不會在RPi3上工作?我的build.gradleAndroid的事情 - 不能使用意識API

compile 'com.google.android.gms:play-services:10.0.0' 
provided 'com.google.android.things:androidthings:0.4-devpreview' 

清單權限

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.INTERNET" /> 

的方法

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()); 
        } 
       }); 
    } 
} 

的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 

出於某種原因,告訴我的權限後停止理所當然的。該應用程序不會崩潰,我有一個OnClickListener調用getWeather(),所以我可以重複點擊,但從來沒有得到任何快照數據。我使用的是手機上的工作原理相同的API密鑰...

按照docs意識API支撐在AndroidThings &我見過的項目是人聲稱在已經使用鄰近&其他API名單。有沒有人在AndroidThings上使用Awareness API獲得成功?

更新播放服務11.0.0之後,應用程序打開立即關閉&現在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 
+1

您是否試過最新版本的AndroidThings? '0.5.0' Play Services'11' https://developer.android.com/things/preview/releases.html – Blundell

+0

Thanks @Blundell。試過閃0.5.0幾次,但沒有運氣。遵循ThingsConsole的方向:創建產品(某些我擁有合適的SOM並保留32MB OEM默認設置)> config product>生成設備映像(帶有空包)>下載和閃存,但是每次屏幕只是空白。你有沒有做特別的事情來創建你的RPi3版本? – JC23

回答

0

總體而言,Android的東西需要的11.0.0最小的播放服務客戶端版本。這是推出Play服務的物聯網變體的版本。這在Support for Google Services的文檔中有記錄。

爲了獲得最佳效果,您應該將庫版本與您正在運行的預覽版本捆綁的確切版本相匹配。您可以在Release Notes上找到這些版本號。

+0

感謝@Devunwired提供反饋。現在Play服務11.0.0應用程序打開並立即關閉顯示啓動頁面?看到上面的新的logcat。事情版本(0.4.1)沒有從控制檯下載,而是直接從網頁上下載,就像所有以前的版本一樣。閃爍的版本0.5.0(三次)作爲Blundell建議,但始終啓動到一個空白屏幕?每次使用一個空包並可以adb進入包列表,但沒有視頻輸出回到0.4.1?關於如何進行的任何想法? – JC23