I am trying to use ActivityResult APIs as stated here ActivityResult APIs
But it is giving unresolved reference error.
I am using following dependencies
api 'androidx.activity:activity:1.1.0'
api 'androidx.activity:activity-ktx:1.1.0'
api 'androidx.fragment:fragment:1.2.5'
api 'androidx.fragment:fragment-ktx:1.2.5'
As per the Getting a result from an activity guide:
So using the stable versions will not include those APIs. The latest versions of each is alpha07, which would mean your dependencies would be:
NOTE: your activity must extend from
ComponentActivity
, which was introduced in AppCompat 1.1.0 and includes theregisterForActivityResult()
API