4

say I have an app that sends a datamessage with this method

    smsManager.sendDataMessage(String destinationAddress, String scAddress, short destinationPort,
  byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent);

say the person who sent it has the app and the person receiving it doesn't have the app, if the person who didn't have the app installs the app is there a way to look in the system for that data message to confirm a phonenumber of the person who originally sent it

JRowan
  • 6,824
  • 8
  • 40
  • 59

3 Answers3

2

...if the person who didn't have the app installs the app is there a way to look in the system for that data message...

In a word, no. Data messages are not handled by the system, beyond receiving. They are merely discarded by the SMS Content Provider, and therefore are not saved anywhere by default. Your app would have to be installed at the time of receipt.

Mike M.
  • 38,532
  • 8
  • 99
  • 95
  • I think you are probably right compared to the other answer can you provide a source or tell me how you know this, i cant find anything on it – JRowan Sep 22 '15 at 15:18
  • Oh, jeez, I am so sorry! I never saw your comment. Uh, I just know this through experience. I did a quick search for something official, but didn't find anything. You can test it, though, by setting up a `ContentObserver` on the `content://sms/` URI, and sending yourself a data message. You'll see that the SMS Provider never assigns the message an ID, and merely discards it. (I misspoke in my initial answer.) – Mike M. Oct 09 '15 at 02:53
  • 1
    Ok, thanks alot ill test it later but im gona take your word from experience on it for now, i cant believe theres nothing out there in documentation, thanks again – JRowan Oct 09 '15 at 03:33
0

Most probably no. Because if a device receives an data sms, all the apps will receive a broadcast, if they are registered for it. After this point the data is available to the apps. If you are very very very lucky, one of these apps could save the data to a publicly accessible area, and you could grab it from there, but I suggest you not to rely on it.

grytrn
  • 423
  • 3
  • 7
-1

As long as the receiver has kept the sms in their inbox, you can use the following code, from this thread:

// public static final String INBOX = "content://sms/inbox";
// public static final String SENT = "content://sms/sent";
// public static final String DRAFT = "content://sms/draft";
Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);

if (cursor.moveToFirst()) { // must check the result to prevent exception
    do {
       String msgData = "";
       for(int idx=0;idx<cursor.getColumnCount();idx++)
       {
           msgData += " " + cursor.getColumnName(idx) + ":" + cursor.getString(idx);
       }
       // use msgData
    } while (cursor.moveToNext());
} else {
   // empty box, no SMS
}

This code will store all the message data as a string within the msgData variable. You can then search within for your target sender's phone number, your app information, etc. To implement this strategy, you'd simply have to call the above code on the first run of the app. Note that you have also have to add the permission: android.permission.READ_SMS in case you hadn't already.

Community
  • 1
  • 1
Gnarlywhale
  • 4,030
  • 2
  • 15
  • 18