Ujang
Ujang

Reputation: 77

Intercept received SMS in Delphi XE5 for Android

Is it possible to intercept received SMS from Android in Delphi XE5 as per this java code How to read the incoming message using service in background in android?.

Upvotes: 6

Views: 4061

Answers (3)

ioan ghip
ioan ghip

Reputation: 1222

Yes! You can! There is a Android BroadcastReceiver example in my answer right here. Just modify the code to get the SMS events like in the article you linked in your question.

Upvotes: 0

Lars D
Lars D

Reputation: 8563

Here is some Delphi code for reading data from the SMS inbox:

http://delphi-android.blogspot.dk/2013/10/how-to-fetch-sms-messages-from-android.html

Upvotes: 2

FerretDriver
FerretDriver

Reputation: 371

Unfortunately there is no way to get Java events in delphi unless embarcadero specifically coded those events.

You can call pretty much any function or method in any class through various means but not events. Therefore you can't get the onReceive event of the broadcast receiver. The java class cannot be inherited from so you cannot override the event.

Best other option available would be to poll to check for messages but Delphi XE5 android apps can't be made into services yet..

If polling works for your needs you can follow this link: Reading text from SMS, and show it as text view

The Delphi equivalent of some of those calls:

cursor: JCursor;

uri: Jnet_Uri;

cursor := SharedActivity.getContentResolver.query(ENTER URL HERE, nil, nil,nil,nil);

while (cursor.moveToNext) do

// processing

Upvotes: 4

Related Questions