android - Grab intent information from a service, only once -


i running service. ideal process call method once, intent/extras , set parameters, run service given amount of time.

from understanding, oncreate() called once, while onstartcommand called every time service called. puts me in backward situation, method want called once, doesn't have access intent extras, , don't want reassign parameters each time startservice called through method has intent access (or should not care happening?).

is way go getting want happen way want it, restrict ability start service if running?

thanks in advance.

put static int flag in oncreate , raise 1 on first call check in onstartcommand whether flag 1 or 0 if 0 ever u want else nothing

  static int flag=0; public void oncreate() {     // todo auto-generated method stub     super.oncreate();     flag=1 } public int onstartcommand(intent intent, int flags, int startid) { if(flag==0){ //run ur code } } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -