0

i made a service of android in my app,when my app is service i want to check if my phone recieve call while my app is running in the background ,how can i do it?:

public class CallService extends Service {
    @Override
    public IBinder onBind(Intent arg0) {
        // TODO Auto-generated method stub
        return null;
    }
    public void onCreate(){
        super.onCreate();
        Toast.makeText(this, "Service Started", Toast.LENGTH_SHORT).show();
    }
    public void onDestroyed(){
        Toast.makeText(this, "Service Destroyed", Toast.LENGTH_SHORT).show();
        super.onDestroy();
    }
}

thanks in advance

fsdf fsd
  • 1,301
  • 4
  • 13
  • 13
  • This is pretty much the same question: http://stackoverflow.com/questions/2771648/how-to-show-incoming-call-notification-in-android-application – Jim Sep 21 '12 at 16:40
  • thanks for help, however i dont understand: the code in this page: http://stackoverflow.com/questions/2771648/how-to-show-incoming-call-notification-in-android-application where do i need to add it in my code?also, do i need to start my app run as service in order to catch phone call while my app is in background? thanks – fsdf fsd Sep 21 '12 at 20:36
  • I haven't done this myself, but I would try to create something like IncomingCallIntercepter in the onCreate() of your CallService. Or more like [this question](http://stackoverflow.com/questions/6036295/not-able-to-get-the-telephonymanager-call-state-ringing), you may not need a service at all depending on what you want your app to do. – Jim Sep 21 '12 at 22:22
  • hi, so can i do on function oncreate of the activity to call to IncomingCallIntercepter instead of starting an service? i still didnt understand the whole concept – fsdf fsd Sep 21 '12 at 22:35
  • Like i said, I haven't done it myself, and I don't have time right now to build a demo app to try it. Give it a shot and see what happens, the worst you can do is have the OS close your app down. The best you can do is learn something new and have fun doing it. – Jim Sep 24 '12 at 15:52

0 Answers0