I have an activity for display new sms and SmsReceiver (extends BroadcastReceiver) to receive incoming sms. After receive sms, what is the best practice to update the UI?
I have an activity for display new sms and SmsReceiver (extends BroadcastReceiver) to receive
Share
Well if you have your own activity it is obious that you want you activity to be shown after the user receive a sms. Then in your receiver , onReceive method you can do this
and the activity is presented to the user…
If you want to put additional info you can use putExtra(“key”,”value”) (it is method from the intent)
you can use like
then in the activity onCreate method you can get this info by
and like this you can implement your business logic
Edit
when the activity is already running you can use
android:launchMode=[“multiple” | “singleTop” |
“singleTask” | “singleInstance”]
I think singleInstance and singleTask will keep only one instance of your activity