Intercept activityForResult from anywhere withing your application, all you need is a Context
Proxy.with(context = applicationContext).listener { requestCode, resultCode, data ->
// handle the result
if(resultCode == Proxy.RESULT_INTENT_UNHANDLED){
// in this case the intent that you have provided does not match to an activity in this device.
}
}.launch(Intent(Intent.ACTION_GET_CONTENT).apply { type = "image/*" }, requestCode = MY_REQUEST_CODE)
requestCode
is optional
In your ProjectLevel build.gradle
allprojects {
repositories {
jcenter()
}
}
In your AppLevel build.gradle
dependencies {
implementation 'org.legobyte:onactivityresult:1.0.4'
}
Please note if your get error when publishing to Google ERROR getting 'android:label' attribute: attribute is not a string value
add lines below to module's AndroidManifest.xml
file until i publish a new version:
<activity
tools:node="replace"
android:theme="@style/ProxyTheme"
android:name="org.legobyte.onactivityresult.ProxyActivity"
android:screenOrientation="unspecified"
android:configChanges="screenSize|screenLayout|fontScale|keyboardHidden|keyboard|orientation|colorMode|density|layoutDirection|locale|mcc|mnc|navigation|smallestScreenSize|touchscreen|uiMode" />
Copyright 2019 LegoBytes
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.