richarth wrote:
> Hi,
> 
> I'm trying to create a broadcast receiver which responds to system
> events and change system settings.  I don't need any interaction from
> the user so I don't need an activity and have been trying to do
> everything through the manifest file.  I've put a log event into my
> onReceive method but it never logs anything so I'm presuming my method
> is never called.  I've tried this with both the 1.5 and 1.6 SDKs.  I
> was hoping somebody could have a look at my code please and let me
> know if there are any problems.
> 
> Manifest file
> 
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android";
>       package="uk.co.richarth"
>       android:versionCode="1"
>       android:versionName="1.0">
>     <application android:icon="@drawable/icon" android:label="@string/
> app_name">
> 
> 
>     <receiver
> android:permission="android.permission.ACCESS_NETWORK_STATE"
> android:enabled="true" android:name=".BroadcastReceiverExample">
>     <intent-filter>
>     <action
> android:name="android.intent.action.AIRPLANE_MODE_CHANGED"></action>
>     </intent-filter>
>     </receiver>
> </application>
>     <uses-sdk android:minSdkVersion="2" />
> 
> <uses-permission
> android:name="android.permission.ACCESS_NETWORK_STATE"></uses-
> permission>
> 
> </manifest>
> 
> Class
> 
> package uk.co.richarth;
> 
> import android.content.BroadcastReceiver;
> import android.content.Context;
> import android.content.Intent;
> import android.util.Log;
> 
> public class BroadcastReceiverExample extends BroadcastReceiver {
> 
>       @Override
>       public void onReceive(Context arg0, Intent arg1) {
>               Log.d("debug", "working");
> 
>       }
> 
> }
> 
> Thanks for the help

You just want your <uses-permission> element, not the android:permission
attribute. Also, you may wish to move that <uses-permission> up earlier
in the XML -- some of this stuff seems (unfortunately) a bit
position-dependent.

Nothing else leaps out at me. Check logcat and see if you get any
warnings -- if Android has difficulty invoking some component, that
tends to get logged as a warning.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Need Android talent? Ask on HADO! http://wiki.andmob.org/hado

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to