android - Unable to dismiss intent activity in libgdx -
i have developed game on libgdx
in trying share text content using intent
. intent activity shown when click on share button in game. problem activity keeps popping when click button. unable dismiss activity , go game screen.the android code below,
public class mainactivity extends androidapplication implements androidintent{ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); androidapplicationconfiguration cfg = new androidapplicationconfiguration(); cfg.usegl20 = true; cfg.useaccelerometer = true; cfg.usecompass = false; initialize(new mygame(this), cfg); } @override public void share() { log.d("magicwords", "sharing game"); intent intent = new intent(intent.action_send); intent.settype("text/plain"); intent.putextra(intent.extra_text, "this status line"); startactivity(intent.createchooser(intent, "share using")); } }
androidintent
interface has share()
.
i have found problem.it due touchlistener. single touch interfaces such options , menus, 1 should use gdx.input.justtouched(). if need touch , drag feauture, use gdx.input.istouched(). since used istouched(), multiple calls intent activity sent. posted code here others lookup.
@override public void render(float delta) { gdx.gl.glclearcolor(0, 0, 0.0f, 1); gdx.gl.glclear(gl10.gl_color_buffer_bit); camera.update(); // coordinate system specified camera. batch.setprojectionmatrix(camera.combined); batch.begin(); batch.draw(...); batch.end(); //for single touch down if(gdx.input.justtouched()) { processtouch((int)touchpos.x, (int)touchpos.y); } //for continuous touch(drag) if(gdx.input.istouched()) { processtouch((int)touchpos.x, (int)touchpos.y); } }
Comments
Post a Comment