android - Push notification turns off my app -
i´m doing game on android. i´m using gcm push notifications , i´m doing push check content in order know if push has winner or loser value , if has win value , user on screen "waiting result" app goes other activity screen (waiting or loser screen depending on push value). schema is:
if user on waiting screen , push comes goes push screen value.
all work on android 4.2.x on 4.1.x , earliest (the last version support 2.3.6) doesnt work when push comes , devices on sleep mode, on case ( api<16 , push comes , device in sleep mode) app turn off ,not errors turn off, , need start again. in order solve trouble have written following lines , force tha app working, , works ,but problem screen turn on always, never goes sleep mode , ,as can imagine, battery dead fast in case not playing in monent. schema problem new implementation is:
when android version<4.1.x , screen on sleep mode. push comes , screen on (always) waiting user screen unlock.
my questions is: have ideas why app turns off on api<16? have implementation idea?
this function inside gcmintentservice extends intentservice class runs in case push notification has win value
if(win){ datastore.userrefereewin=true; if (currentusersituation().contains("waiting") && (android.os.build.version.sdk_int < 16)){ powermanager pm = (powermanager) getapplicationcontext().getsystemservice(context.power_service); wakelock wakelock = pm.newwakelock((powermanager.screen_bright_wake_lock | powermanager.full_wake_lock | powermanager.acquire_causes_wakeup), "tag"); wakelock.acquire(); } sound = uri.parse("android.resource://" + getpackagename() + "/" + whatwinsound()); intent recentappintent = new intent(gcmintentservice.this, win.class); recentappintent.addflags(intent.flag_activity_new_task); contentintent = pendingintent.getactivity(getbasecontext(), 1, recentappintent, 0); }
thanks in avenced
Comments
Post a Comment