android - Passing data from Activity A to Service B to Activity C -


i want pass data activity service b username , phonenumber. in service b phonenumber (here phone number important) used , randomnumber generated. data passed service b activity c username, phonenumber , randomnumber.

i trying use code given below not work.

in activity a:

intent gotoserviceb = new intent(getapplicationcontext(),serviceb.class); gotoserviceb.putextra("passedphonenumberatos", phonenumberstr); gotoserviceb.putextra("passedusernameatos", usernamestr); startservice(gotoserviceb); 

in service b:

public int onstartcommand(intent intent, int flags, int startid) {     // todo auto-generated method stub     string phonenumber = intent.getstringextra("passedphonenumberatos");     string username = intent.getstringextra("passedusernameatos");     return service.start_not_sticky; } 

in service b there intent:

intent gotoactivityc = new intent(getapplicationcontext(),activityc.class); gotoactivityc.putextra("passedphonenumberstoa", phonenumberstr); gotoactivityc.putextra("passedusernamestoa", usernamestr); gotoactivityc.putextra("passedrandomnumberstoa", randomnumberstr); startactivity(gotoactivityc); 

in activity c:

intent intent=new intent(); string phonenumber = intent.getstringextra("passedphonenumberstoa"); string username = intent.getstringextra("passedusernamestoa"); string randomnumber=intent.getstringextra("passedrandomnumberstoa"); 

my logcat:

08-03 14:19:42.882: e/trace(1923): error opening trace file: no such file or directory        (2) 08-03 14:19:44.983: d/gralloc_goldfish(1923): emulator without gpu emulation detected. 08-03 14:19:45.153: w/iinputconnectionwrapper(1923): showstatusicon on inactive   inputconnection 08-03 14:19:47.792: d/dalvikvm(1923): gc_concurrent freed 84k, 7% free 2765k/2972k, paused 79ms+46ms, total 236ms 08-03 14:20:03.792: d/dalvikvm(1923): gc_for_alloc freed 54k, 6% free 2931k/3104k, paused 36ms, total 57ms 08-03 14:20:03.812: i/dalvikvm-heap(1923): grow heap (frag case) 4.050mb 1127536-byte allocation 08-03 14:20:03.964: d/dalvikvm(1923): gc_for_alloc freed 50k, 6% free 3982k/4208k, paused 152ms, total 152ms 08-03 14:20:04.113: d/dalvikvm(1923): gc_concurrent freed 1k, 6% free 3987k/4208k, paused 4ms+97ms, total 154ms  08-03 14:20:04.202: d/androidruntime(1923): shutting down vm 08-03 14:20:04.202: w/dalvikvm(1923): threadid=1: thread exiting uncaught exception (group=0x40a71930)  08-03 14:20:04.232: e/androidruntime(1923): fatal exception: main 08-03 14:20:04.232: e/androidruntime(1923): java.lang.illegalstateexception: not execute method of activity 08-03 14:20:04.232: e/androidruntime(1923):     @ android.view.view$1.onclick(view.java:3599) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.view.view.performclick(view.java:4204) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.view.view$performclick.run(view.java:17355) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.os.handler.handlecallback(handler.java:725) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.os.handler.dispatchmessage(handler.java:92) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.os.looper.loop(looper.java:137) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.app.activitythread.main(activitythread.java:5041) 08-03 14:20:04.232: e/androidruntime(1923):     @ java.lang.reflect.method.invokenative(native method) 08-03 14:20:04.232: e/androidruntime(1923):     @ java.lang.reflect.method.invoke(method.java:511) 08-03 14:20:04.232: e/androidruntime(1923):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 08-03 14:20:04.232: e/androidruntime(1923):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 08-03 14:20:04.232: e/androidruntime(1923):     @ dalvik.system.nativestart.main(native method) 08-03 14:20:04.232: e/androidruntime(1923): caused by: java.lang.reflect.invocationtargetexception 08-03 14:20:04.232: e/androidruntime(1923):     @ java.lang.reflect.method.invokenative(native method) 08-03 14:20:04.232: e/androidruntime(1923):     @ java.lang.reflect.method.invoke(method.java:511) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.view.view$1.onclick(view.java:3594) 08-03 14:20:04.232: e/androidruntime(1923):     ... 11 more 08-03 14:20:04.232: e/androidruntime(1923): caused by: android.view.windowmanager$badtokenexception: unable add window -- token null not application 08-03 14:20:04.232: e/androidruntime(1923):     @ android.view.viewrootimpl.setview(viewrootimpl.java:571) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.view.windowmanagerglobal.addview(windowmanagerglobal.java:246) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:69) 08-03 14:20:04.232: e/androidruntime(1923):     @ android.app.dialog.show(dialog.java:281) 08-03 14:20:04.232: e/androidruntime(1923):     @ com.beproject.groupmessenger.userregistration.showalert(userregistration.java:91) 08-03 14:20:04.232: e/androidruntime(1923):     @ com.beproject.groupmessenger.userregistration.submit(userregistration.java:97) 08-03 14:20:04.232: e/androidruntime(1923):     ... 14 more 

can 1 please give simple solution above problem? have searched lot unable understandable solution.

java.lang.illegalstateexception: not find method submit(view) in activity class com.beproject.groupmessenger.userregistration onclick handler on view class android.widget.button id 'register'

the error logcat indicate problem unrelated data passing code.

this error indicates have button android:id="@+id\register" defined in xml userregistration activity has click handler set android:onclick="submit". however, android not find submit(view) method in userregistration activity, , crashes error.

make sure userregistration activity has public submit(view) method, , application should no longer crash.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -