简体   繁体   English

从android应用中的摄像头捕获图像后,单击onActivityResult()中的按钮

[英]click a button inside onActivityResult() after capturing an image from camera in android app

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == PICK_CONTACT_REQUEST) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {
            //Button Click
        }
    }
}

Here if the RESULT_OK,how to click a button and do whatever we want. 如果是RESULT_OK,如何单击按钮并执行我们想要的任何操作。 Please Help me to find the solution.I have used if(getTaskId()==R.id.PassImageBtn){} but nothing is happening if I click on the Button. 请帮助我找到解决方案。我已经使用过if(getTaskId()==R.id.PassImageBtn){}但是如果单击Button则什么也没有发生。

Use performClick () method to the call button click event. 使用performClick ()方法调用按钮的单击事件。

private Button mButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_layout);
    mButton = findViewById(R.id.my_button);
    mButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // ...
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == PICK_CONTACT_REQUEST) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {
            mButton.performClick();
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从android中的相机捕获图像后,图像未显示在活动中 - image not displaying inside an activity after capturing the image from camera in android Android 5.1.1 默认相机在捕获图像后在 onActivityResult 中返回空意图 - Android 5.1.1 default camera return empty intent in onActivityResult after capturing image Android:通过摄像头捕获照片后无法调用onActivityResult()方法 - Android: Not able to call onActivityResult() method after capturing photo by camera Android 使用相机意图捕获图像后应用程序崩溃 - Android App crashes after capturing image using camera intent 从相机捕获图像上的应用程序在奇巧android中崩溃 - on capturing image from camera the app is crashing in kitkat android 在Android中从相机捕获后增加图像的亮度和对比度 - Increase Brightness and Contrast of image after capturing from camera in Android 通过意图从相机捕获后如何裁剪图像:Android - how to crop image after capturing from camera through intent : Android 在Android 4.1.2中捕获图像后,onActivityResult()给出空值 - onActivityResult() gives null value after capturing image in Android 4.1.2 在android中单击相机后无需按确定按钮即可从相机获取图像 - Get image from camera without pressing ok button after camera click in android Android-OnActivityResult按钮单击 - Android - OnActivityResult Button Click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM