How to handle a incoming phone call

Put your problem here if it does not fit any of the other categories.

How to handle a incoming phone call

Postby bibiodp » Wed Nov 28, 2007 11:07 am

Hello,

I'm having issue trying to handle a phone call. I'm trying with an intentReceiver but it doesn't seem to work... Since I don't know how to make a incoming phone call on the emulator, I tried to handle others actions such as TIME_TICK but I doesn't seem to work either...

First, what I've done :
AndroidManifest.xml :
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.bibi">
    <application android:icon="@drawable/icon">
        <activity class=".App" android:label="@string/app_name">
            <intent-filter>   
                <action android:value="android.intent.action.MAIN" />
            </intent-filter>
            <receiver class=".OutGoingCallReceiver">
               <intent-filter>
                   <action android:value="android.intent.action.DIAL" />
                   <action android:value="android.intent.action.TIME_TICK" />
               </intent-filter>
           </receiver>
        </activity>
    </application>
</manifest>



My IntentReceiver :

Code: Select all
public class OutGoingCallReceiver extends IntentReceiver {

   @Override
   public void onReceiveIntent(Context context, Intent intent) {
      NotificationManager nm = NotificationManager.from(context);
      nm.notifyWithText(12555,"Action : " +  intent.getAction(),NotificationManager.LENGTH_LONG,null);
      Log.w(App.class.toString(),"Action : " + intent.getAction());
   }
   
   public OutGoingCallReceiver(){}

}



But when the "time ticks" (minute changes) nothing happens.


So I have several questions :

1. Does the emulator broadcast all action like it should or is it limited?
2. Is my code OK?


Thanks :)
I'm a poor lonesome French developper ;)
bibiodp
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Nov 26, 2007 6:18 pm

Top

Postby plusminus » Wed Nov 28, 2007 11:29 am

Hello bibiodp,

Simulating an incoming call with the emulator works as the following:

I'll transform this into a real tutorial this evening (@ GMT +1 ;) ) as I am not home right now (university).
  1. The emulator has to be running :!:
  2. Open the Ttelnet-Client of your choice (on xp is should already be installed, on probably have to install it later on)
  3. type to it: "o localhost 5554" // dunno exactly which port, could also be 5555... have a try.
    I. "o" stands for "Open", "localhost" is the 'IP' and "5554" is the port the telnet-server is listening to.
  4. Connection should establish in a few seconds.
  5. type: "gsm call 123456" to simulate an incoming call.
  6. See the emulator ringing :)

I'll have a look at the Intent-Receiving issue, when I'm back home, as the lunch-break is passing by now ;)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby bibiodp » Wed Nov 28, 2007 12:29 pm

First thanks for replying so fast :)

I opened an msdos console and launched "telnet" (winXP telnet Client isn't easy to use and I love command line ;))

So I typed your commands and it works!! I see the incoming call on the emulator.

But I my intentReceiver is still not called...
So I tried this in my main activity:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.broadcastIntent(new Intent("android.intent.action.CALL"), null, new OutGoingCallReceiver(), null, Activity.RESULT_OK, null, null);
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

With this line my intentReceiver is called (I see the popup and the log).
Maybe that the OS is not using that kind of broadcast? I'm a bit lost a this point :(
I'm a poor lonesome French developper ;)
bibiodp
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Nov 26, 2007 6:18 pm

Postby plusminus » Wed Nov 28, 2007 3:46 pm

Hello bidibop,

the bug was so close that we couldn't see it ^^. Your are listening to the wrong Intent. :!:
See their Javadoc:
public static final String CALL_ACTION
Activity Action: Perform a call to someone specified by the data.

public static final String DIAL_ACTION
Activity Action: Dial a number as specified by the data.


Both are "active" Intents, when you want to do sth.

I solved the problem of being identified of a new call in another way, I will turn into an Tutorial right now :)

Pleas, be patient for some minutes. I'll inform you here. :!:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby bibiodp » Wed Nov 28, 2007 4:06 pm

Oki thx! So I think you mean that those actions are "user dependant" and what we're looking for here are some kind of "system dependant" actions.

I'll wait for the tut, refreshing the page... ;)

thx again :)
I'm a poor lonesome French developper ;)
bibiodp
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Nov 26, 2007 6:18 pm

Postby plusminus » Mon Dec 17, 2007 8:58 pm

Hey bibiodp,

Sorry, I forgot to post the link to the tutorial here :(
:src: Here it is :src:

Hope you were not still refreshing ;)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 21 guests