I want to implement below functionality in my app.
How can i do this?
I have 2 ways in my mind :
Get total post count from webservice after every 1 minute or some time.
But for that I need to run one Thread
continuously in background so may be performance issue will arise.(Battery performance)
Can I do this functionality with Notification
service?
or If any one have another Idea please suggest me.
It would be good idea to do it with push notification
. You can set flag in push notification and filter it according to your need.
create Broadcast
which will be called when you receive notification
of perticular flag.
Intent intent = new Intent("newStory");
sendBroadcast(intent);
on that broadcast receive method show that Image
or Layout
.
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("receiver", "Got message: ");
//show new story image
}
};
In onResume()
register your Broadcast
.
registerReceiver(mMessageReceiver, new IntentFilter("newStory"));
In onPause()
unregister it.
unregisterReceiver(mMessageReceiver);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With