0

Possible Duplicate:
I am afraid: SMS send from within an app seem impossible to detect?

Sending an SMS from an app in Android is really easy:

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, position, pi, null);

But it seem that all these SMS are "invisible" and the user will never know an SMS has been sent!

-> All SMS applications (Go SMS, Handcent, stock app, etc..) does not show these SMS.

-> These sent SMS does not seem to fire an Intent.

SO, my question is rather simple: how can I track all these SMS and find if an application is malicious?

I don't want to wait till the end of the month to check my bill, it will be too late!

Community
  • 1
  • 1
Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • 1
    Please note the polite way to bring more visibility to a question on Stack Overflow is to [post a bounty](http://stackoverflow.com/faq#bounty). Thanks. – sarnold Jun 27 '11 at 22:15

3 Answers3

0

Instead of sending the message like this, you could fire an intent that would get handled by the default SMS application. That would lead to your text showing.

Take a look at this SO post:

send SMS Intent in Android

EDIT:

AFAIK, there is no intent broadcast when Android sends an SMS.

Community
  • 1
  • 1
hwrdprkns
  • 7,525
  • 12
  • 48
  • 69
  • I don't think that's what the OP is asking. IMO the OP is asking how to figure out how many messages are sent by other applications. – Chris Thompson Jun 21 '11 at 17:38
  • Answer edited. Feel free to correct me, but I don't think Android broadcasts a system intent when it sends an SMS. – hwrdprkns Jun 21 '11 at 17:39
  • I think you're right...short of modifying the system code, I don't know of any way to do this – Chris Thompson Jun 21 '11 at 17:42
  • Hello hwrdprkns, thank a lot for your kind answer. Unfortunately 1) I am not able to change the code of other apps to detect their send SMS 2) This feature is useless as the Aim of my other apps is to send location by SMS when you lost your phone. 3) how can your code help to detect malicious app. – Waza_Be Jun 21 '11 at 18:04
  • @Profete162: As I said, I don't think Android broadcasts a message when an SMS is sent. – hwrdprkns Jun 21 '11 at 18:10
0

You have to make your own BroadcastReceiver and pass your string into that with the PendingIntent. So it could look something like this...

    private static final String SENT_SMS      = "com.your.stuff.SMS_SENT";
    private static final String DELIVERED_SMS = "com.your.stuff.SMS_DELIVERED";
    private static final String SMS_RECEIVED  = "android.provider.Telephony.SMS_RECEIVED";

The system does however, tell you when the message went out with Activity.RESULT_OK. There are other messages if it is not ok such as SmsManager.RESULT_ERROR_GENERIC_FAILURE so on and so forth. You can check that in the BroadcastReceiver that you set up...

this.sentReceiver = new BroadcastReceiver() {

    @Override
public void onReceive(final Context pContext, final Intent pIntent) {
// Get the result code
switch ( this.getResultCode() ) {
    case Activity.RESULT_OK:
        // Do something that pertains to the SMS going out ok like adding one to your outgoing count
        break;
    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
        // do something
        break;
    case SmsManager.RESULT_ERROR_NO_SERVICE:
        // do something
        break;

    ...

    default:
        break;
}

};

http://developer.android.com/reference/android/telephony/SmsManager.html

rf43
  • 4,385
  • 3
  • 23
  • 28
  • Thank a lot! This is a great first step.. So, from what I understand I will only be able to detect SMS sennd from within my app but not from other apps? – Waza_Be Jun 21 '11 at 18:56
  • AFAIK that is correct... I haven't tested it but I think that all broadcasts are picked up by the system therefore you could, in theory, set up a receiver and receive any intent. The way to control the information though is via permissions. – rf43 Jun 21 '11 at 19:12
0

Without any other solutions, the answer seem to be "NO, there is no solutions".

That's a big security issue, in my mind.

Waza_Be
  • 39,407
  • 49
  • 186
  • 260