Perfect replacement for startActivityForResult(), based on the Activity Result API.

Overview

ActivityResultLauncher

English | 中文

Activity Result API is an official tool used to replace the method of startActivityForResult() and onActivityResult(). But the API is not very friendly to use, so this library helps you use the Activity Result API in as many scenarios as possible with easier to use code, it also supports encapsulating the function that projects use with startactivityForResult()

Feature

  • Replace startActivityForResult() perfectly
  • Support for the usage of Kotlin and Java
  • Support for taking picture
  • Support for taking video
  • Support for selecting pictures or videos (Adapted to Android 10)
  • Support for cropping pictures (Adapted to Android11)
  • Support for requesting permission
  • Support for enabling Bluetooth
  • Support for enabling positioning
  • Support for the use of storage access frameworks
  • Support for selecting contacts

Demo

screenshot

Click or scan the QR code to download

QR code

Gradle

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        // ...
        maven { url 'https://www.jitpack.io' }
    }
}

Add dependencies:

dependencies {
    implementation 'com.github.DylanCaiCoding:ActivityResultLauncher:1.0.1'
}

Wiki

Kotlin usage

Java usage

Others

Change log

Releases

Author's other libraries

  • LoadingHelper, a highly expandable Android library for decoupling the code of toolbar or loading status view.
  • ViewBindingKTX, the most comprehensive utils of ViewBinding.

License

Copyright (C) 2021. Dylan Cai

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
A logger with a small, extensible API which provides utility on top of Android's normal Log class.
A logger with a small, extensible API which provides utility on top of Android's normal Log class.

This is a logger with a small, extensible API which provides utility on top of Android's normal Log class. I copy this class into all the little apps

Android library which makes it  easy to handle the different obstacles while calling an API (Web Service) in Android App.
Android library which makes it easy to handle the different obstacles while calling an API (Web Service) in Android App.

API Calling Flow API Calling Flow is a Android library which can help you to simplify handling different conditions while calling an API (Web Service)

Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.

Trail Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platfor

Expirable Disk Lru Cache is a secure(with encryption) wrapper for [DiskLruCache](https://github.com/JakeWharton/DiskLruCache) that allows expiring of key/value pairs by specifying evictionTimeSpan. It has very simple API.

ExpirableDiskLruCache ExpirableDiskLruCache is a wrapper for DiskLruCache that allows expiring of key/value pairs by specifying evictionTimeSpan. It h

The REST API backend server for the Jalgaon CoHelp application.

API Service - Jalgaon CoHelp The REST API backend server for the Jalgaon CoHelp application. 🛠 Technology / Tools used Kotlin: Programming language f

⚙ A beautiful and extensible API for bulding preferences screen
⚙ A beautiful and extensible API for bulding preferences screen

Material Preferences 💻 Installation Add this in app's build.gradle file: implementation 'com.imangazaliev.material-prefs:core:version' implementati

A modern contacts Android API.
A modern contacts Android API.

A modern contacts Android API.

SSI/NFC desktop/terminal API
SSI/NFC desktop/terminal API

Gimly SSI Card Terminal Gimly SSI Card Terminal is a REST API for Self Sovereign Identity interactions between apps, servers, terminals having an NFC

Consumer android from nutrition-framework API
Consumer android from nutrition-framework API

About This Project (work-in-progress 👷 🔧️ 👷‍♀️ ⛏ ) Consumer Dari Nutrition Framework General Framework for Application Development Around Nutrition

Comments
  • 请教一下在非Activity/Fragment 中启动,是否无法接收onActivityResult返回值

    请教一下在非Activity/Fragment 中启动,是否无法接收onActivityResult返回值

        final StartActivityLauncher startActivityLauncher = new StartActivityLauncher(UpdateAppActivity.this);
    

    // Uri packageURI = Uri.parse("package:" + AppUtils.getPackageName(getBaseContext())); // Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI); // startActivityLauncher.launch(intent, new ActivityResultCallback() { // @Override // public void onActivityResult(ActivityResult result) { // if(result.getResultCode()== Activity.RESULT_OK){ // // } else { // // } // } // });

    上面代码注释的部分如果在Activity/Fragment 中是能正常的工作的,能拿到onActivityResult 值。但是在该Activity/Fragment 启动的下载安装线程不能接收到返回值,是因为?

    opened by AnyLifeZLB 1
  • provider冲突

    provider冲突

    manifest清单文件中定义的provider和其他第三方有冲突android:name="androidx.core.content.FileProvider"。建议自己定义一个provider继承androidx.core.content.FileProvider,定义在清单文件中,这样就不存在冲突了。

    opened by jianjunxiao 0
  • 能否增加方法

    能否增加方法

    BaseActivityResultLauncher里有

      public void launch(@SuppressLint("UnknownNullness") I input, @Nullable ActivityOptionsCompat options,
                         @NonNull ActivityResultCallback<O> callback) {
        this.callback = callback;
        launcher.launch(input, options);
      }
    

    StartActivityLauncher及所有类都没提供此方法,好像这个平时用得不多 刚好有需求要某个Activity启动时改变切换效果,就要用到了,希望能对外增加此方法,谢谢

    opened by Samdogcom 1
  • 报Failed to resolve

    报Failed to resolve

    因为是出学者,所以使用方法可能不对想请教一下

    根目录 build.gradle

    `// Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript { repositories { google() mavenCentral() maven { url 'https://www.jitpack.io' } }

    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    

    } task clean(type: Delete) { delete rootProject.buildDir }`

    app下的build.gradle

    `plugins { id 'com.android.application' }

    android { compileSdk 31

    defaultConfig {
        applicationId "com.misachu.cameraalbumtest"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"
    
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    

    }

    dependencies {

    //.........//
    implementation 'com.github.DylanCaiCoding:ActivityResultLauncher:1.1.2'
    

    }`

    然后报错了 Failed to resolve: com.github.DylanCaiCoding:ActivityResultLauncher:1.1.2

    请问一下要如何使用?

    opened by uminosaki 0
Releases(1.1.2)
Owner
DylanCai
DylanCai
Native Kotlin library for time-based TOTP and HMAC-based HOTP one-time passwords

A kotlin implementation of HOTP (RFC-4226) and TOTP (RFC-6238). Supports validation and generation of 2-factor authentication codes, recovery codes and randomly secure secrets.

Robin Ohs 6 Dec 19, 2022
Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.

Disk LRU Cache A cache that uses a bounded amount of space on a filesystem. Each cache entry has a string key and a fixed number of values. Each key m

Jake Wharton 5.7k Dec 31, 2022
A lightning fast, transactional, file-based FIFO for Android and Java.

Tape by Square, Inc. Tape is a collection of queue-related classes for Android and Java. QueueFile is a lightning-fast, transactional, file-based FIFO

Square 2.4k Dec 30, 2022
Gesture detector framework for multitouch handling on Android, based on Android's ScaleGestureDetector

Android Gesture Detectors Framework Introduction Since I was amazed Android has a ScaleGestureDetector since API level 8 but (still) no such thing as

null 1.1k Nov 30, 2022
Multiplaform kotlin library for calculating text differences. Based on java-diff-utils, supports JVM, JS and native targets.

kotlin-multiplatform-diff This is a port of java-diff-utils to kotlin with multiplatform support. All credit for the implementation goes to original a

Peter Trifanov 51 Jan 3, 2023
A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML

A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion.

null 603 Jan 1, 2023
Gitversion - A native console application to calculate a version based on git commits and tags

GitCommit A native console application to calculate a version based on git commi

Solugo 5 Sep 13, 2022
Flow-based programming "language"

________ / ____/ /___ _ __ / /_ / / __ \ | /| / / / __/ / / /_/ / |/ |/ / /_/ /_/\____/|__/|__/ Flow-based programming "language" This

Kevin Ludwig 2 Dec 17, 2022
Flow-based programming "language"

Cran Flow-based programming "language", the aim of this project is not to create an entry-friendly programming language, and more over to create a cap

Kevin Ludwig 3 May 30, 2022
Validator - Notify type based validation for input fields.

Validator - Notify type based validation for input fields.

Mustafa Yiğit 57 Dec 8, 2022