java - Android broadcast receiver to scan every incoming SMS for specific Contant -


I want to scan every incoming SMS for specific content. When special content is found then a special task is done. Let's assume that the specific content string is "Hello World" when the service finds this string then it will trigger a specific task. Take a photo with the i.e. front camera and place that photo on a specific folder. The receiver has to always run when the phone is on.

Create an SMS broadcast receiver for this that triggers a SMS received

  Public class SMSBroadcastReceiver broadcasts broadcasts receivers {Private constant final string SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"; Private static final string TAG = "SMSBroadcastReceiver"; Override public zero at @Receive (reference reference, intention intent) {Log.i (TAG, "intent received:" + intent.getAction ()); If (intent.getAction () == SMS_RECEIVED) {bundle bundle = intent.getExtras (); If (bundle! = Null) {object [] pdus = (object []) bundle.get ("puds"); Last SMS Message [] Message = New SMS Message [pdus.length]; For (int i = 0; i & lt; pdus.length; i ++) {message [i] = smsmssecreditprodupa ((byte []) pdus [ii]); } If (messages.length & gt; -1) {Log.i (TAG, "Message received:" + Message [0] .getMessageBody ()); }}}}}   

Inside the receiver, you can check for the received text and take special action.

Also declare it in the manifest,

   & Lt; / Intent-Filter & gt; & Lt; / Receiver & gt;   

Also announce the permissions,

  & lt; Use-permission Android: name = "android.permission.INTERNET" & gt; & Lt; / Usage-permission & gt; & Lt; Usage-permission Android: name = "android.permission.RECEIVE_SMS" & gt; & Lt; / Usage-permission & gt;    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -