notifications - Best way to implement a GMail like notifier in Android -
notifications - Best way to implement a GMail like notifier in Android -
i'm looking create notifier type app android. sits in background , performs lookup via net every often, , notifies of of import incoming data.
whats best way this? how can create run @ selected intervals, battery friendly?
the gmail notifications in android seem check email connect internet. there way code same?
thanks!
right off bat, should mention technique describe in question called polling. thing polling isn't battery/resource friendly , want remain away much possible (in mobile realm).
now given description of problem, want push solution. that's how android's gmail client works. android's native force solution called c2dm , it's freely available versions 2.1+.
now how work?
the general thought this: using gmail example, server (i.e. backend) receives new email user x
. server send targeted message app installed on x
's device @ point app contact server , retrieve message.
now allow me briefly describe polling:
app: hey, got me? server: nope app: sleep bit app: hey, got me? server: nope app: sleep bit app: hey, got me? server: yep, here is! ...
in latter example, app consumed resources without accomplishing whereas in force scenario, one phone call server retrieve message. can see how bad polling can on battery life.
android notifications gmail
Comments
Post a Comment