Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the deprecated 'startActivityForResult' #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ansonYam
Copy link

@ansonYam ansonYam commented Jan 5, 2023

I was just stepping through the tutorial and saw that 'startActivityForResult' was deprecated, so I searched for the new way to launch an activity and pasted it here.

@riggaroo riggaroo requested a review from calren June 20, 2023 10:31
@calren
Copy link
Contributor

calren commented Jun 20, 2023

@marcelpinto Feel free to assign to the new owner for bluetoothle

@calren calren removed their request for review June 20, 2023 17:39
}
// [END enable_bluetooth]
}

private val getResult =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: getResult is not really the best name for this. Could you change it to requestResult or activityResult

@@ -28,8 +28,19 @@ class MainActivity : AppCompatActivity() {
// displays a dialog requesting user permission to enable Bluetooth.
if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled) {
val enableBtIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT)
getResult.launch(enableBtIntent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a comment:

// Launch the request with the ActivityResultContracts.StartActivityForResult

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants