debugging - Android Development: Writing a for loop inside onClick with Intent -
debugging - Android Development: Writing a for loop inside onClick with Intent -
i trying application run 5 times after user presses designated button, runs 1 time , prints out debugging statement (log.v) 5 times.
what right format this?
this tried:
button btnstart = (button) findviewbyid(r.id.startservice); btnstart.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { (int = 0; < 5; i++) { intent intent = new intent(currentclass.this, different.class); intent.addflags(intent.flag_activity_new_task); startservice(intent); finish(); log.v(tag, "testing"); } } });
edit:
i tried create service task 5 times, after first time, java.io.ioexception: invalid preview surface. when mmediarecorder.prepare() called, , startrecording() called again.
your service has not yet had chance finish when for()
loop runs 5 times. need implement communication between ui , service - allow service send message when it's done can phone call 1 time again (read on service-activity communication here).
alternatively, modify service whatever 5 times. if info dynamic each time want run service, may have go first approach.
debugging service android-intent onclick
Comments
Post a Comment