0

I'm using the following library to read the sms messages that have been sent from my default application. The problem that I'm having is that when the application is close the service is not working to save the message that i have send. Does anyone knows how i can start the service when a message has been sent from my device?

Library https://github.com/tuenti/SmsRadar

UPDATE 1: BroadcastReceiver class

public class Broadcast_Receiver extends BroadcastReceiver {


    @Override
    public void onReceive(Context context, Intent intent) {

        if(intent.getAction().equals("android.provider.Telephony.SMS_SENT")){
            Intent service = new Intent(context, SMSService.class);
            context.startService(service);
            Log.d("Broadcast_Receiver", "message sent");
        }
        else if ((intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")))
        {
            Log.d("Broadcast_Receiver", "message received");
        }

    }
}

manifest

<receiver android:name=".APPServices.SMS.Broadcast_Receiver" android:enabled="true">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_SENT"/>
    </intent-filter>
</receiver>

Thank you

George Panayi
  • 1,768
  • 6
  • 26
  • 42
  • My answer here might help: http://stackoverflow.com/questions/19083158/send-sms-until-it-is-successful/19084559#19084559 – cYrixmorten Nov 25 '14 at 15:24

1 Answers1

0

You'll need to use a "Broadcast Reciever" for that

As the name suggests: broadcast receiver waits for an event to occur and when the event occurs , it receives that info, which was broadcast-ed by the event.

Here is a great tutorial which describes how to implement it step by step (A little long to type it here)

http://androidexample.com/Incomming_SMS_Broadcast_Receiver_-_Android_Example/index.php?view=article_discription&aid=62&aaid=87

Akshit Rewari
  • 941
  • 2
  • 13
  • 26