startActivityForResult 已被弃用,用于图像按钮从图库中选择照片

时间:2021-07-02 17:47:16

标签: java android deprecated photo android-imagebutton

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost myneptune-cluster.region.neptune.amazonaws.com
255.255.255.255 broadcasthost
::1             localhost

以 onactivityresult 为例:

//Example of ImageButton in the old way how it was handled

img_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            startActivityForResult(photoPickerIntent, 500);

        }
    });

}

我使用的是 jdk 1.8 和 android 6.0, 如何使用未弃用的替代方案更改它?

0 个答案:

没有答案