title: How to finish() Activity if one uses Car Home if Exit Button is pushed?
body: <p>I am trying to create an app for a driving application that can be activated via a Driving button or B) Automatically using a car dock. </p>
  
  <p>I use the UiModeManager to enableCarMode via: </p>
  
  <p>//Set the UI to car mode </p>
  
  <pre><code>UiModeManager UImanager = (UiModeManager)getSystemService(Context.UI_MODE_SERVICE);
  UImanager.enableCarMode(UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME);
  </code></pre>
  
  <p>I have no problem finishing with the manual method of pushing the exit button on my app, however, if the car home is activated then My application is running in the background. Which is what I need. </p>
  
  <p>However, once I use the Car Home's Exit Button on the Emulation mode, I get the Android home screen and my app is running in the background. i.e: There is no way to shut the app down except going back into the app and shutting it down. </p>
  
  <p>If I finish my app after starting the Car Home UI then I have lost my app. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.HelloWord333" android:versionCode="1"
      android:versionName="1.0.0"&gt;
  &lt;uses-sdk android:minSdkVersion="8" /&gt;
  
  
  &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
      &lt;activity android:name=".BBM" android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.CAR_DOCK" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;receiver android:name=".Driving"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.app.action.EXIT_CAR_MODE" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p>            </p>
  
  <p>Once I receive the broadcast receiver, I cannot go back to my main Activity. I have tried to use intent but have had no luck in calling my main Activity. </p>
  
  <pre><code>package com.HelloWorld333;
  
  import android.app.Activity;
  import android.app.PendingIntent;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.os.Bundle;
  import android.telephony.SmsManager;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;  
  import android.app.UiModeManager;
  
  public class Driving extends BroadcastReceiver
  {
      static final String CarDuck = "android.intent.category.CAR_DOCK";
      static final String CarMode = "android.intent.category.CATEGORY_CAR_MODE";
      public static String ACTION_EXIT_CAR_MODE = "android.app.action.EXIT_CAR_MODE";
  
  
  
  
      @Override
      public void onReceive(Context context, Intent intent) 
      {
  
  
  if (intent.getAction().equals(ACTION_EXIT_CAR_MODE)){
  
  Toast.makeText(context.getApplicationContext(),"Houston we have a Exit Car mode", Toast.LENGTH_SHORT).show(); 
  
  ExitFromCarMode = true;
  
  UiModeManager UImanager = (UiModeManager)context.getSystemService(Context.UI_MODE_SERVICE);            
             UImanager.disableCarMode(UiModeManager.DISABLE_CAR_MODE_GO_HOME);
  
             //Context context1 = context.getApplicationContext(); 
  
  //I'm sorry I have tried but no luck in trying to reach my main Activity
  
            // Intent intent1 = new Intent(context1, ExitCarMode.class);
            // intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            // context1.startActivity(intent1);               
      }
  }
  </code></pre>
  
  <p>I tried to use a broadcast receive method in my main Activity class but the app crashes on run time once the Exit button of the car mode is pushed. </p>
  
  <p>I appreciate any help, and look forward to any hints please.</p>
  
  <p>I have been going in circles with this for the last two days, and believe me it is no fun when you miss the hockey game :(.  </p>