I got a user reporting that our app does correctly terminate when the 
user's device exits car mode, but only when the activity that contains the 
receiver is not active. If the activity is in the foreground then more 
often than not our app does not terminate.

The activity is defined as

       <activity

            android:name=".MainScreen"

            android:alwaysRetainTaskState="true"

            android:configChanges="orientation"

            android:label="@string/app_name"

            android:launchMode="singleTask" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

                <category android:name="android.intent.category.CAR_DOCK" />

                <category android:name="android.intent.category.CAR_MODE" />

            </intent-filter>

        </activity>



The receiver is very simple


*private* BroadcastReceiver undockReceiver = *new* BroadcastReceiver() {

@Override

*public* *void* onReceive(Context context, Intent intent) {

    *if* (intent.getAction().equals("android.app.action.EXIT_CAR_MODE")) {

     finish();

    }

}

    };


Is there a reason that the receiver does not work reliably?  Is it bad 
practice to put a receiver inside the main activity? or does it have to do 
with the activity flags?

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to