Coder Social home page Coder Social logo

mxstarter's Introduction

MXStarter

最新版本:

    implementation 'com.gitee.zhangmengxiong:MXStarter:1.2.4'

解决的问题

Android开发中打开Activity并获取结果的原生方法:

    // 启动页面
    startActivityForResult(Intent(this,XXX::class.java), 0x22)

    // 获取结果
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == 0x22){
            // 这里获取结果
        }
    }

当调用多个启动页面时,需要一个个判断requestCode并多次编写if xxx else xxx

使用MXStarter后,调用Activity方法如下:

MXStarter.start(this, ResultActivity::class.java) { resultCode: Int, data: Intent? ->
    // 这里获取结果
}

权限申请功能集成

在Activity和Fragment中可以直接获取权限申请回调,不需要再重载Activity的 onRequestPermissionsResult() 方法获取结果

MXPermission.requestPermission(
            activity,
            arrayOf(
                Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE
            )
        ) { allowed ->
            Toast.makeText(
                this@MainActivity,
                "获取权限:$allowed",
                Toast.LENGTH_SHORT
            ).show()
        }

mxstarter's People

Contributors

zhangmengxiong avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.