-3

I want to read all sms messages from specific number at any time not relating when app is runned or not runned. How can I read all messages when app is not runned, in newer versions of android?

Benfactor
  • 543
  • 4
  • 11
  • 31

1 Answers1

1

You should use a broadcast receiver for this as suggested by @abdul.

1-Add the permission

<uses-permission android:name="android.permission.RECEIVE_SMS"/> 

2-Create a BroadCastreceiver Class

Don't forget to properly handle the permissions on Android 6.0 and above.

You should also probably set a high android:priority for broadcast receiver intent filter.

Important: Please note that this is a very unstable functionality which is not garanteed to work on every Android phone and will largely depend on the system and installed apps.

bvk256
  • 1,837
  • 3
  • 20
  • 38
  • Is it working after phone rebooted? – Benfactor Jul 22 '19 at 14:12
  • @Benfactor for this you need to create a separate broadcast receiver to listen for `BOOT_COMPLETED` event to start the sms broadcast receiver. Please note that this would need the respective permission as well. The example tutorial https://riptutorial.com/android/example/15019/broadcastreceiver-to-handle-boot-completed-events – bvk256 Jul 22 '19 at 14:15