in WorkManagerSample/app/src/main/java/com/example/background/SelectImageActivity.kt [49:86]
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivitySelectBinding.inflate(layoutInflater).apply {
setContentView(root)
}
with(binding) {
// Show stock image credits.
credits.text = fromHtml(getString(R.string.credits))
// Enable link following.
credits.movementMethod = LinkMovementMethod.getInstance()
}
// We keep track of the number of times we requested for permissions.
// If the user did not want to grant permissions twice - show a Snackbar and don't
// ask for permissions again for the rest of the session.
if (savedInstanceState != null) {
permissionRequestCount = savedInstanceState.getInt(KEY_PERMISSIONS_REQUEST_COUNT, 0)
}
requestPermissionsIfNecessary()
binding.selectImage.setOnClickListener {
val chooseIntent = Intent(
Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI
)
startActivityForResult(chooseIntent, REQUEST_CODE_IMAGE)
}
binding.selectStockImage.setOnClickListener {
startActivity(
FilterActivity.newIntent(
this@SelectImageActivity, StockImages.randomStockImage()
)
)
}
}