Skip to content
Receive the activity result directly after the startActivityForResult with InlineActivityResult
Branch: master
Clone or download
Florent Champigny
Florent Champigny updated rx version
Latest commit 84a617b Mar 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci initial import Mar 21, 2018
.idea updated rx version Mar 19, 2019
gradle updated rx version Mar 19, 2019
inline-activity-result-kotlin use kotlin coroutines last stable version Mar 16, 2019
inline-activity-result-rx renamed Sep 11, 2018
inline-activity-result add missing InlineActivityResult Mar 16, 2019
medias initial import Mar 21, 2018
sample use kotlin coroutines last stable version Mar 16, 2019
.gitignore
LICENSE initial import Mar 21, 2018
README.md
_config.yml initial import Mar 21, 2018
build.gradle updated rx version Mar 19, 2019
gradle.properties updated rx version Mar 19, 2019
gradlew initial import Mar 21, 2018
gradlew.bat initial import Mar 21, 2018
publish.sh renamed Sep 11, 2018
settings.gradle renamed Sep 11, 2018

README.md

Inline Activity Result

Language

Work in progress

Receive the activity result directly after the startActivityForResult with InlineActivityResult, choose your way :

No need to override Activity or FragmentonActivityResult(code, permissions, result)using this library, you just have to execute InlineActivityResult's methods This will not cut your code flow

General Usage (cross language)

Download

dependencies {
    implementation 'com.github.florent37:inline-activity-result:(lastest version)'
}
startForResult(this, new Intent(MediaStore.ACTION_IMAGE_CAPTURE), new ActivityResultListener() {
      @Override
      public void onSuccess(Result result) {
          //the started activity result is RESULT_OK
      }

      @Override
      public void onFailed(Result result) {
          //the started activity result is RESULT_CANCEL
      }
});

Kotlin-Coroutines

launch(UI) {
   try {
       val result = startForResult(Intent(MediaStore.ACTION_IMAGE_CAPTURE))

       //use the result, eg:
       val imageBitmap = result.data?.extras?.get("data") as Bitmap
       resultView.setImageBitmap(imageBitmap)
   } catch (e: InlineActivityResultException) {

   }
}

Download

Download

implementation 'com.github.florent37:inline-activity-result-kotlin:(last version)'

Kotlin

startForResult(Intent(MediaStore.ACTION_IMAGE_CAPTURE)) { result ->
     //use the result, eg:
     val imageBitmap = result.data?.extras?.get("data") as Bitmap
     resultView.setImageBitmap(imageBitmap)
}.onFailed { result ->

}

Download

Download

implementation 'com.github.florent37:inline-activity-result-kotlin:(last version)'

RxJava

new RxInlineActivityResult(this).request(new Intent(MediaStore.ACTION_IMAGE_CAPTURE)))
    .subscribe(result -> {
        //use the result, eg:
        Bundle extras = result.getData().getExtras();
        Bitmap imageBitmap = (Bitmap) extras.get("data");
        resultView.setImageBitmap(imageBitmap);
    }, throwable -> {
        if (throwable instanceof RxInlineActivityResult.Error) {
            final Result result = ((RxInlineActivityResult.Error) throwable).getResult();

        }
    })

Download

implementation 'com.github.florent37:inline-activity-result-rx:(last version)'

Java8

new InlineActivityResult(this)
       .startForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE))
       .onSuccess(result -> {
           //use the result, eg:
           Bundle extras = result.getData().getExtras();
           Bitmap imageBitmap = (Bitmap) extras.get("data");
           resultView.setImageBitmap(imageBitmap);
       })
       .onFail(result -> {
            
       });

Download

Download

implementation 'com.github.florent37:inline-activity-result:(last version)'

Java7

startForResult(this, new Intent(MediaStore.ACTION_IMAGE_CAPTURE), new ActivityResultListener() {
      @Override
      public void onSuccess(Result result) {
          Bundle extras = result.getData().getExtras();
          Bitmap imageBitmap = (Bitmap) extras.get("data");
          resultView.setImageBitmap(imageBitmap);
      }

      @Override
      public void onFailed(Result result) {

      }
});

How to Contribute

We welcome your contributions to this project.

The best way to submit a patch is to send us a pull request.

To report a specific problem or feature request, open a new issue on Github.

Credits

Author: Florent Champigny http://www.florentchampigny.com/

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2018 florent37, Inc.

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 can’t perform that action at this time.