My situation is that I want to call a particular method to get called from ClassA from inside my ClassB which extends the BroadcastReceiver class. I understand how to do this from inside another class file etc and how to setup the BroadcastReceiver, or so I thought.
Below is the class file that extends the BroadcastReceiver.
The method that I am trying to call does work great in the application if I manually request it. In my AndroidManifest.xml I added thisCode:public class WatchPhone extends BroadcastReceiver { private ClassA classA = new ClassA(); @Override public void onReceive(Context context, Intent BackToMain) { // TODO Auto-generated method stub TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); int state = telephony.getCallState(); switch(state) { case TelephonyManager.CALL_STATE_RINGING: Log.d("TestServiceReceiver", "IDLE"); classA.IwantToDoThis(); break; } }
and this at the bottom just above the closing application tag.Code:<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
When the phone rings, the application crashes then closes. Any ideas on what I should do.Code:<receiver android:name=".WatchPhone"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver>


LinkBack URL
About LinkBacks
Reply With Quote