views:

273

answers:

2

if google voice is installed on your phone, when you dial a phone number a context menu pops up asking if you want to dial with or without google voice. I would like to accomplish the same task for dialing a number or sending a text message. Does the API allow you to do that?

It seems there is a process_outgoing_calls, in the permissions manifest, but is there anything for the SMS?

A: 

I don't know if there is a way to intercept outgoing_sms. There is one for intercepting received ones.

You can reading smspopup src code to get some ideas.

Macarse
+2  A: 

I haven't tested this myself, but you should be able to listen for the "sms-to" intent by adding this intent-filter to your manifest for a corresponding activity (from the system mms/sms app - http://bit.ly/9JjHGd):

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.SENDTO" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
        </intent-filter>
AdamK
I will give this a shot tomorrow. Super Bowl on the mind right now. How would something like this work? Do I need to have a broadcast receiver that listens for outgoing calls, and one for outgoing sms's? Any examples of using this kind of stuff online would be helpful. Thank you!
Hallik
I have tried the following, setup a broadcastreceiver class, but when I try sending a text on the emulator, the onReceive method is never fired. Suggestions?I used the code you have above except I wrapped it inside a receiver: <receiver android:name=".SMSBlockReceiver"> ... ... </receiver>Perhaps I need to run a service in the background? I am trying to monitor an SMS sent from the main android messaging app.
Hallik
It turns out you can't do this in Android yet. :\
Hallik
Whoops, sorry for the slow response. I somehow only noticed your comments now. Where did you hear this was not possible? This might not be possible for calls but it is definitely possible for SMS. I tried it myself and it worked.Start a brand new Android project, and within the Activity it creates add the intent-filter I originally posted (under the intent-filter it creates for you). Then go to a contact, create a new SMS and it will ask you to choose either the system app or the new app.
AdamK
Note: you cannot use a broadcast receiver, it has to be part of an activity (a broadcast is not sent when a new SMS is created).
AdamK
This does indeed work, it launches my application instead of the native one, i was wondering AdamK if you know how to get the data from the contact selected to appear in my application though? So I choose home from contacts and click send message and the number for home should appear in my applications send to: edit text?
Donal Rafferty