Can we intercept tel: urls?

hackhack

Active Member
Licensed User
Longtime User
Normally the "tel:" prefix will launch the dialer - can we register an app to be called instead when a "tel:" url is launched?
 
Well if you add

Code: Copy
AddActivityText(Main,
<intent-filter>
                  <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.DIAL" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="tel" />
</intent-filter>)

To the manifest editor, that will tell the system that this app can handle it and optionally launch the app.

BUT we don't get any information on the payload, zip, zilch, null, nothing.

But if its to prevent the dialer bug, this is enough it seems :)
 
Upvote 0
So if one adds to the manifest what I added above, and in Globals define

Code: Copy
Dim i As Intent

Then in Activity_Create

Code: Copy
i=Activity.GetStartingIntent
   If i.Action="android.intent.action.MAIN" Then
      Msgbox ("Hi","You just started the app")
   Else
      Msgbox("This number trigged this app:",i.GetData)
   End If

The msgbox will show you "tel:" and the number which triggered the activation of the app, or if the user just ran it.
 
Last edited:
Upvote 0
You do not need to declare a global variable. You can declare i as a local variable.

You should move this code to Activity_Resume (Activity_Create will only be called if the activity was not created before).

It is better to explicitly check for that intent and also verify that GetData is not null opr empty:
Code: Copy
Else If i.Action = "android.intent.action.DIAL" AND i.GetData <> Null AND i.GetData <> "" Then 
 ...
End If
 
Upvote 0
This is great. :icon_clap:
I have a problem with triggering this action from dialler or phone book... Could this be added how?
 
Upvote 0
I have a problem with triggering this action from dialler or phone book... Could this be added how?
The dialer dials the phone number, it most probably doesn't send any intent. The same may be true for the phone book app. You should check the unfiltered logs and see if any intent is being sent when press on the dial button.
 
Upvote 0
Hi, this is great.

What is get out from log, is bellow. Also what is interesting, is also this: mUseSipPhone = false
Attachment: this menu is activated

log1 - csipsimple not integrated with system dialer, wifi on, direct call
D/PhoneInterfaceManager( 1536): mUseSipPhone = false
I/ActivityManager( 1395): Starting activity: Intent { act=android.intent.action.CALL dat=tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.InCallScreen (has extras) } from pid 1536


log2 - csipsimple integrated with system dialer, wifi on, sip chosen
I/ActivityManager( 1395): Starting activity: Intent { act=android.intent.action.CALL dat=csip:909 flg=0x10000000 cmp=com.csipsimple/.ui.OutgoingCallChooser } from pid 3809


log3 - csipsimple integrated with system dialer, wifi on, sim chosen
I/ActivityManager( 1395): Starting activity: Intent { act=android.intent.action.CALL dat=csip:909 flg=0x10000000 cmp=com.csipsimple/.ui.OutgoingCallChooser } from pid 3809
I/ActivityManager( 1395): Starting activity: Intent { act=android.intent.action.CALL dat=tel:xxx-xxx-xxxx cmp=com.android.phone/.OutgoingCallBroadcaster } from pid -1
W/ActivityManager( 1395): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.CALL dat=tel:xxx-xxx-xxxx cmp=com.android.phone/.OutgoingCallBroadcaster }


log4 - csipsimple integrated with system dialer, wifi on, sim chosen, nothing chosen
I/ActivityManager( 1395): Starting activity: Intent { act=android.intent.action.CALL dat=csip:909 flg=0x10000000 cmp=com.csipsimple/.ui.OutgoingCallChooser } from pid 3809


log5 - csipsimple integrated with system dialer, wifi off, nothing chosen
D/PhoneInterfaceManager( 1536): mUseSipPhone = false
I/ActivityManager( 1395): Starting activity: Intent { act=android.intent.action.CALL dat=tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.InCallScreen (has extras) } from pid 1536
 

Attachments

  • 2012-10-15_15-18-18.jpg
    2012-10-15_15-18-18.jpg
    42.3 KB · Views: 572
Upvote 0
So, this it the result

Manifest:
Code: Copy
AddActivityText(Main,
<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.CALL" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="csip" />
</intent-filter>)


Code: Copy
If i.Action = "android.intent.action.CALL" AND i.GetData <> Null AND i.GetData <> "" Then 
         Msgbox(i.GetData, "This number trigged this app CALL")
End If

If csipsimple is "integrated with system dialer", I get picture in attachment. Otherwise ther call goes directly through SIM.
So...does any body know what is mUseSipPhone and how to set it?

Thanks
 

Attachments

  • 2012-10-15_15-46-44.jpg
    2012-10-15_15-46-44.jpg
    53.1 KB · Views: 609
Upvote 0
Hi everyone. Maybe someone had same problem? If I put intent-filter into Service module, I get the following error:

Code: Copy
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=csip:7536 flg=0x10000000 (has extras) }

In Main works great.
 
Last edited:
Upvote 0
Maybe someone has luck with passing Extras throu Intent tel:?

I trie to read with Eclipse, btu there are no extras for this.
Code: Copy
Value1 = intent.getStringExtra("Value1");

Code: Copy
Sub Call(telNumber As String)
    Dim i As Intent
    i.Initialize(i.ACTION_CALL, "tel:" & telNumber.Replace("#", "%23"))
   'i.PutExtra("Value1", "test2")
   i.PutExtra("android.phone.extra.ALREADY_CALLED",True)
   StartActivity(i)
 End Sub

Code: Copy
D/OutgoingCallInterceptor( 6789): A - Value1: Bundle[{android.phone.extra.ALREADY_CALLED=false, android.phone.extra.ORIGINAL_URI=tel:9000, android.intent.extra.PHONE_NUMBER=9000}]
 
Upvote 0
Back
Top