Skip to content

Latest commit

 

History

History
49 lines (28 loc) · 815 Bytes

README.md

File metadata and controls

49 lines (28 loc) · 815 Bytes

ActCaller

Activity#startActivityForResult()+onActivityResult()转变为Callback形式

使用

  1. 添加依赖

    allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }
    
    implementation 'com.github.andych008:ActCaller:1.1'
    
  2. 以从相册选取图片为例

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_PICK);
    intent.setType("image/*");
    
    new ActCaller(activity).startForResult(intent, new ActCaller.Callback() {
        @Override
        public void onActivityResult(int resultCode, Intent data) {
             if (result.getResultCode() == Activity.RESULT_OK) {
                 Uri  photoPathUri = result.getData().getData();
             }
        }
    });