0

I want to read incoming sms body in android only when application is open not when application is closed.

i know how to detect incoming SMS body i used broadcast receiver for that and am showing toast in broadcast reciver in onRecieve() method am showing toast it works nicely but problem is dat when my app is closed am outside of app and SMS comes it shows toast ,

My problem is dat i dont want that toast when application is not on foreground or app is not opened

thanks in advance

2 Answers2

0

You can use below code to disable your receiver which is declared in manifest.
usePackageManager pm = Re_editActivity.this.getPackageManager(); ComponentName componentName = new ComponentName(currentActivity.this,name_of_your_receiver.class); pm.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);

Ankit
  • 256
  • 1
  • 9
0

hi guys finaly i got my solution hre is the link http://khurramitdeveloper.blogspot.in/2013/07/receive-sms-using-android.html