Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法解除libgdx中的意图活动_Android_Android Intent_Libgdx - Fatal编程技术网

Android 无法解除libgdx中的意图活动

Android 无法解除libgdx中的意图活动,android,android-intent,libgdx,Android,Android Intent,Libgdx,我在libgdx上开发了一个游戏,在这个游戏中,我试图使用Intent共享文本内容。当我在游戏中单击共享按钮时,就会显示意图活动。问题是,即使我单击“上一步”按钮,活动也会不断弹出。我无法取消活动并返回游戏屏幕。android代码如下: public class MainActivity extends AndroidApplication implements AndroidIntent{ @Override public void onCreate(Bundle savedI

我在
libgdx
上开发了一个游戏,在这个游戏中,我试图使用
Intent
共享文本内容。当我在游戏中单击共享按钮时,就会显示意图活动。问题是,即使我单击“上一步”按钮,活动也会不断弹出。我无法取消活动并返回游戏屏幕。android代码如下:

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 the game");
        Intent intent = new Intent(Intent.ACTION_SEND); 
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "this is the status line");
        startActivity(Intent.createChooser(intent, "Share using"));

    }
}

androident
是我的界面,它有
share()

我发现了问题。这是由于touchlistener。对于选项和菜单等单触式界面,应使用Gdx.input.justtouch()。如果需要触摸和拖动feauture,请使用Gdx.input.isTouched()。由于我使用了isTouched(),因此发送了对intent活动的多个调用。在此处发布代码供其他人查找

    @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 by the 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);
    }
}