Created
January 11, 2020 13:12
-
-
Save shikto1/4cd29f0bf6257cbc45a7e38d0990315c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GoodActivity extends AppCompatActivity { | |
| private BroadcastReceiver mBroadcastReceiver; | |
| @Override | |
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_first); | |
| mBroadcastReceiver = new BroadcastReceiver() { | |
| @Override | |
| public void onReceive(Context context, Intent intent) { | |
| //your receiver code goes here! | |
| } | |
| }; | |
| } | |
| @Override | |
| protected void onStart() { | |
| super.onStart(); | |
| registerReceiver(mBroadcastReceiver, new IntentFilter("SmsMessage.intent.MAIN")); | |
| } | |
| @Override | |
| protected void onStop() { | |
| super.onStop(); | |
| if(mBroadcastReceiver != null) { | |
| unregisterReceiver(mBroadcastReceiver); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment