service - Best practices for pubnub on android -


i'm using pubnub publish/subscribe channel between android app , server. i'm thinking of how implement this.

i'm using provided library android (https://github.com/pubnub/pubnub-api/tree/master/android) think there problems application lifecycle if use now. (correct me if i'm wrong)

i thinking of implementing service

what want

  • the service has keep on running until hour (negotiable) after last app usage. that's because want have notifications when message comes in, app not used app.

  • how stop service after 1 hour of non-activity of app? android kill it, want control.

  • the service must able trigger app change it's interface when specific messages come in (i thinking of sending intents service when receive pubnub message?), pubnub send data service, need way pass data application (probably save in bundle in intent?)

  • i need listen multiple pubnub channels (max 2 @ same time), think have in multiple instances of service?

i think this:

  • create service that's started when app starts

  • let service listen pubnub channel

  • when message comes in, send intent , use intent filters

  • implement broadcasthandlers listen these internal intents

is right way this? hints?

you have excellent set of questions detailed points talk in answer. using android , interested in conventions , best practices pubnub publish/subscribe scenarios.

your use case common , best ways build apps vary dependent on application needs. have right idea , have asked right questions. needed sample code , direction started on implementing specifics of application needs. define needs in list:

  • connect/disconnect ability.
  • always-on background service can send/receive data , notify other apps via android intents.
  • connecting multiple pubnub channels @ same time.

so started provide direct links examples , methods:

regarding thoughts - is right way it:

  • create service that's started when app starts
  • let service listen pubnub channel.
  • when message comes in, send intent , use intent filters.
  • implement broadcasthandlers listen these internal intents.

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -