Also the manifest is requiring that whoever sends the broadcast to it hold
the BROADCAST_STICKY permission, which is unnecessary and really I'd say
outright wrong.  Also the manifest is requesting that permission, which it
does not need, and the BATTERY_STATS permission, which it does not need and
also can not get.

On Wed, Jul 18, 2012 at 2:13 PM, Mark Murphy <[email protected]>wrote:

> You cannot register for ACTION_BATTERY_CHANGED in the manifest. You
> can only listen for this broadcast via registerReceiver() from an
> existing, running component.
>
> On Wed, Jul 18, 2012 at 3:57 PM, krishna kumar <[email protected]>
> wrote:
> > Hi All
> >
> > Not working my recever why ?
> >
> > here my code please help me
> >
> > ====
> > import android.content.BroadcastReceiver;
> > import android.content.Context;
> > import android.content.Intent;
> > import android.util.Log;
> >
> > public class MyRecever extends BroadcastReceiver {
> >
> >     @Override
> >     public void onReceive(Context context, Intent intent) {
> >
> >
> >        int level = intent.getIntExtra("level", 0);
> >        Log.i("MyRecever", "--->>"+level);
> >
> >
> >     }
> >
> > }
> > ====manifest.xml===
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >     package="my.custom"
> >     android:versionCode="1"
> >     android:versionName="1.0" >
> >
> >     <uses-sdk android:minSdkVersion="7" />
> >     <uses-permission android:name="android.permission.BROADCAST_STICKY"/>
> >     <uses-permission android:name="android.permission.BATTERY_STATS"/>
> >
> >     <application
> >         android:icon="@drawable/ic_launcher"
> >         android:label="@string/app_name" >
> >         <activity
> >             android:name=".CustomserviceActivity"
> >             android:label="@string/app_name" >
> >             <intent-filter>
> >                 <action android:name="android.intent.action.MAIN" />
> >
> >                 <category
> android:name="android.intent.category.LAUNCHER" />
> >             </intent-filter>
> >         </activity>
> >         <receiver android:name="MyRecever"
> >             android:enabled="true"
> >              android:permission="android.permission.BROADCAST_STICKY">
> >             <intent-filter>
> >                 <action
> > android:name="android.intent.action.BATTERY_CHANGED"/>
> >             </intent-filter>
> >         </receiver>
> >     </application>
> >
> > </manifest>
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
>
>
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 3.8 Available!
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to