Do the following:
1. In your manifest you should have
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission
android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission
android:name="android.permission.READ_PHONE_STATE"/>
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
<action android:name="Test" />
</intent-filter>
2. Register your broadcast receiver in the main activity
IntentFilter filter = new IntentFilter
("bct.com.MyEventReceiver");
eventRcvr = new MyEventReceiver();
this.registerReceiver(eventRcvr, filter);
3. Implement a Broadcast receiver
public class MyEventReceiver extends BroadcastReceiver {
...
public void onReceive(Context context, Intent intent) {
System.out.println("Receiver Object in onReceive: "+this);
NewPhoneStateListener phoneListener=new NewPhoneStateListener
();
TelephonyManager telephony = (TelephonyManager)
context.getSystemService
(Context.TELEPHONY_SERVICE);
telephony.listen
(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
Log.d(TAG,"intent:"+intent.toString());
}
...
}
4. New Class
public class NewPhoneStateListener extends PhoneStateListener {
public void onCallStateChanged(int state,String incomingNumber){
switch(state)
{
//whatever you want to do here
}
}
}
--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.
On Aug 17, 1:45 pm, "[email protected]" <[email protected]>
wrote:
> I'm trying to write an app that will run when the phone rings but NOT
> answer the incoming call. The app would have an answer button that
> when pressed would perform the regular call answer action, but this
> isn't what I need help with.
>
> I've searched the internet and haven't been able to find any consensus
> on this issue. My app only needs to run during the call ringing stage
> and nothing more. What would I have to listen for to do this and what
> manifest entries would I need? Forgive my incorrect/nonexistant use
> of terminology, I haven't worked with Android in close to a year and
> haven't freshened up fully yet.
>
> Thank you
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---