0

I implemented openFileChooser of webchromeclient which is opening a PHP page. When i select image from gallery it again opens the gallery ie the gallery is opening two times.

Don't know how to get rid of this.

here is my code:

public class MyWebChromeClient extends WebChromeClient{
    public void openFileChooser(ValueCallback<Uri> uploadMsg) {

        mUploadMessage = uploadMsg;
        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType("image/*");
        startActivityForResult(Intent.createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE);

    }

    public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType ) {
        mUploadMessage = uploadMsg;
        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType("*/*");
        startActivityForResult(
                Intent.createChooser(i, "File Browser"),
                FILECHOOSER_RESULTCODE);
    }
}

this is onactivityresult:

protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {


    if (requestCode == FILECHOOSER_RESULTCODE) {
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != RESULT_OK ? null
                : intent.getData();
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;

    } 
}
4

1 回答 1

0

签入清单文件,如果您将活动声明为

单实例

那么 Activity on result 方法将在错误的时间被调用。

于 2012-11-29T11:11:55.463 回答