Sunday, October 10, 2010

[android-developers] BroadcastReceiver not working for Car Dock

I'm trying to write a program to send an email when the phone is
placed in the car dock. I have create a Android Project with no
Activities.

Below is the one class I have created. It just has a Toast so I can
see that it is working. Below is the code which I think is correct.

package com.demo.carmode;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public class CarMode extends BroadcastReceiver {

@Override
public void onReceive(Context arg0, Intent intent) {
Toast.makeText(arg0, "Hello Car Mode", Toast.LENGTH_SHORT).show();
Log.d("ExmampleBroadcastReceiver", "intent=" + intent);
Log.i("CarMod", "hello world");
}
}

My mainfest is real simple also.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.carmode" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<receiver android:name=".CarMode" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.CAR_DOCK"></
category>
</intent-filter>
</receiver>
</application>
</manifest>

I'm testing the code by click on the phone Car Home app. Would this
not be the same thing as docking the phone?

Have I not setup my manifest correctly? Could I be missing something
else. Seems like this should work. I also see the active and
category appear on my logcat.

Thanks for the help

Zach

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate