Following is the receiver
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
public class ServiceReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
MyPhoneStateListener phoneListener=new MyPhoneStateListener();
TelephonyManager telephony = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen
(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
}
}
On Mar 2, 1:55 pm, Marco Nelissen <[email protected]> wrote:
> On Mon, Mar 2, 2009 at 11:49 AM, Bnet <[email protected]> wrote:
>
> > Thanks for your time Marco, added the following to the manifest. There
> > is an error in MyPhoneStateListener as shown below:
>
> > <activity android:name=".SoundNotification">
> > <intent-filter>
> > <action
> > android:name="android.intent.action.SoundNotification" />
>
> You should use the same string here that you use for the intent
> action, i.e. "com.bnet.detectmissedcall.SoundNotification"
>
> > </intent-filter>
> > </activity>
>
> > Error: The method startActivity(Intent) is undefined for the type
> > MyPhoneStateListener
>
> > Intent i = new Intent("com.bnet.detectmissedcall.SoundNotification");
> > startActivity(i);
>
> You will need to have a Context to call startActivity() on. It's not
> clear to me how you create your PhoneStateListener, but the Activity
> or Service that you create it in should have a Context for you to use.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---