Search code examples
javaandroidandroid-auto

Checking CarConnection app crashes with SecurityException - RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED


in Android 34, App crashes with SecurityException: com.mgg.timmi: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts.

This crash happens when calling in Android 34

  new CarConnection(this).getType().observe(this, new Observer<Integer>() {
        @Override
        public void onChanged(Integer integer) {
            Log.d(TAG, "CarConnection status changed");
        }
    });

Observer and Oberserverable are deprecated, so what else can I use to check if device is connected with Android Car.

I'm using implementation car.app:1.2.0.

thanks GGK


Solution

  • For apps that target API 34 or higher running on an API 34 or higher device, you'll need to use 1.3.0-beta01 or higher as described at https://developer.android.com/training/cars/apps#car-connection.