android - Refer an integer from Service to Service -


i building app needs pass integer 1 service other service.

firstservice

package com.jebinga.myapp;    import android.app.service; import android.content.intent; import android.hardware.sensor; import android.hardware.sensorevent; import android.hardware.sensoreventlistener; import android.hardware.sensormanager; import android.os.bundle; import android.os.handler; import android.os.ibinder; import android.util.log; import android.view.menuitem; import android.widget.textview;      public class firstservice extends service implements sensoreventlistener {  int value1=10;    @override     public void oncreate() {     super.oncreate();           bundle korb=new bundle();         korb.putint("ente", value1);          intent in = new intent(firstservice.this, secondservice.class);         in.putextra("korb", korb);         this.startservice(in);             system.err.println("firstservice value1: "+value1);          }         @override     public ibinder onbind(intent intent) {         // todo auto-generated method stub         return null;     }    } 

secondservice

package com.jebinga.myapp;  import android.annotation.suppresslint; import android.app.service; import android.content.context; import android.content.intent; import android.os.bundle; import android.os.handler; import android.os.ibinder; import android.provider.settings; import android.provider.settings.global; import android.util.log;  public class secondservice extends service{        int value2;          public void onstartcommand(intent intent, int startid){          super.onstartcommand(intent, startid, startid);             bundle zielkorb = intent.getextras();          int value2 = zielkorb.getint("ente");             system.err.println("secondservice value2:="+value2);                }          @override     public ibinder onbind(intent intent) {         // todo auto-generated method stub         return null;     } } 

due log know value1 in firstservice 10 should be. value2 0 though should 10.

what did wrong? can me?

you packed bundle intent, , value bundle. need read them out, first bundle, , value.

bundle zielkorb = intent.getbundleextra("korb"); int bvalue = zielkorb.getint("ente"); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -