0

I created a text listener like this (below) in the manifest file. I assume the listener will always be enabled in any activity (thus wasting battery).

    <receiver 
      android:name="com.me.basic.SMSReceiverActivity"
      android:enabled="true">
      <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
      </intent-filter>
    </receiver>

But in my app, there are lots of activities, and only one of them requires the text listening to be on. Is there a code I can use to disable and enable this listener?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
omega
  • 40,311
  • 81
  • 251
  • 474
  • Have you tried this... http://stackoverflow.com/questions/5624470/enable-and-disable-a-broadcast-receiver ? – user387184 Jul 15 '12 at 21:12
  • @user387184 , i took a look at it, but I don't understand it still... – omega Jul 15 '12 at 21:15
  • I would expect CommonsWare's solution to work for you by just replacing the onBootReceiver with your onSMSReceiver class – user387184 Jul 15 '12 at 21:20
  • i'm getting a variable not found error on 'prefs', 'key' and 'EditPreferences'. What do I replace for these? – omega Jul 15 '12 at 21:28

0 Answers0