Notification runs then immediately crashes
<p>I have proximity alerts set up. (ADDED CRASH LOG)</p>

<p>When the proximity alert fires, I want a notification to load. Then when the user clicks the notification, a new activity/form should load.</p>

<p>Right now, the notification runs then the app crashes.  The notification text is received and displayed successfully though.</p>

<p>Does anyone see something wrong with my code that would cause it to crash when firing the notification?</p>

<p><strong>This code sets up the proximity alert/notification</strong></p>

<pre><code>    public void SetupProximityAlerts(LocationManager lm, String name, String info, double latitude, double longitude, int range)
{
    Intent intent = new Intent(PROX_ALERT_INTENT);
    intent.putExtra("Name", name);
    intent.putExtra("Info", info);

    PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    lm.addProximityAlert(latitude, longitude, range, -1, pi);
    IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);

    registerReceiver(new MyBroadcastReceiver(), filter);
}
</code></pre>

<p><strong>And here is my BroadcastReceiver which sets the data to display in the notification.  The app crashes when running: nm.notify(0, n);</strong></p>

<p>Everything up until nm.notify(0, n); runs successfully. I've verified this with logging. </p>

<pre><code>public class MyBroadcastReceiver extends BroadcastReceiver
 {

@Override
public void onReceive(Context context, Intent intent)
{
    Bundle extras = intent.getExtras();

    String deal = (String) extras.get("Info");

    Intent notificationIntent = new Intent(context, ViewTarget.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    Resources res = context.getResources();

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setContentIntent(contentIntent).setSmallIcon(R.drawable.icon).setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.icon)).setTicker(deal).setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentTitle("Message")
            .setContentText(deal);
    Notification n = builder.getNotification();

    n.defaults |= Notification.DEFAULT_ALL;

    nm.notify(0, n);
}
}
</code></pre>

<p><strong>And here is the activity I want to load when the user clicks the notification</strong></p>

<pre><code>public class ViewTarget extends ListActivity
{

@Override
public ListAdapter getListAdapter()
{
    // TODO Auto-generated method stub
    return super.getListAdapter();
}

@Override
public ListView getListView()
{
    // TODO Auto-generated method stub
    return super.getListView();
}

@Override
public void setListAdapter(ListAdapter adapter)
{
    // TODO Auto-generated method stub
    super.setListAdapter(adapter);

}

@Override
protected void onCreate(Bundle savedInstanceState)
{
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.locations);
    Log.v("db", "Inside ViewTarget");
}

}
</code></pre>

<p>Here is the crash log</p>

<pre><code>04-17 21:53:52.407: E/AndroidRuntime(4717): FATAL EXCEPTION: main
04-17 21:53:52.407: E/AndroidRuntime(4717): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.kjdv.gpsVegas.MyBroadcastReceiver (has extras) } in com.kjdv.gpsVegas.MyBroadcastReceiver@44a4bc30
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:905)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.os.Handler.handleCallback(Handler.java:587)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.os.Looper.loop(Looper.java:123)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at java.lang.reflect.Method.invokeNative(Native Method)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at java.lang.reflect.Method.invoke(Method.java:521)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at dalvik.system.NativeStart.main(Native Method)
04-17 21:53:52.407: E/AndroidRuntime(4717): Caused by: java.lang.SecurityException: Requires VIBRATE permission
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.os.Parcel.readException(Parcel.java:1247)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.os.Parcel.readException(Parcel.java:1235)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:274)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.app.NotificationManager.notify(NotificationManager.java:110)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.app.NotificationManager.notify(NotificationManager.java:90)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at com.kjdv.gpsVegas.MyBroadcastReceiver.onReceive(MyBroadcastReceiver.java:51)
04-17 21:53:52.407: E/AndroidRuntime(4717):     at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:892)
04-17 21:53:52.407: E/AndroidRuntime(4717):     ... 9 more
</code></pre>

<p>Thanks!
Kevin</p>
