0

I am developing SMS blocking app in Android which block incoming message for blocked contact and store that message in my app database.Now I have created one UI in which I can read blocked message and also reply that contact(Just like chat view).Now my problem is that whenever I am in that UI and there is new message for blocked contact, I can't see in my UI , but when I close and again open that app I see that new message.

So my problem is how do I show new message in my UI when I am currently on that view

Thanks in advance

Antarix
  • 665
  • 1
  • 10
  • 29

2 Answers2

0

What you have to do is listen for new SMS by Registering ContentObserver to content://sms/

See in that post how you can register a ContentObserver to content://sms/

Practical way to find out if SMS has been sent

and you can also download working example from here Contentovserver

Community
  • 1
  • 1
Diego Palomar
  • 6,958
  • 2
  • 31
  • 42
0

I know this may not be the most correct answer but what I did is I made static reference to my ListView , Adapter and ArrayList<MyObject> and then in my Activity I added one static flag variable

public static boolean isShowing;

and onCreate() menthod I set isShowing = true; and onStop() method set isShowing=false;

now in my BroadcastReceiver I check if activity is showing than update the listview

in my case this worked for me, hope it may help someone else

Antarix
  • 665
  • 1
  • 10
  • 29