Android Studio: onActivityResult not being executed after closing gallery - android

I am new to android development and trying to teach myself. Currently I am trying to add a functionality in my app where I click a button and the gallery opens up for a user to select an image to be used later and then a dialog box is supposed to show up after the gallery closes. However, after closing the gallery nothing happens and it seems that the onActivityResult() code does not run for some reason. I get no error in logcat and Log.d statments do not show up. Code below. Thanks!
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Log.d("TEST1", "FUN EXECUTED")
val fab = view.findViewById<FloatingActionButton>(R.id.fababc)
fab.setOnClickListener {
showCreateTodoList()
Log.d("TEST2", "RECIEVING INPUT")
}
}
private fun showCreateTodoList() {
openGallery()
}
private fun openGallery() {
val gallery = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI)
requireActivity().startActivityForResult(gallery, p)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(resultCode == AppCompatActivity.RESULT_OK && requestCode == p){
Log.d("TESTING", "THIS CODE RUNS")
imageURI = data!!.data
activity?.let {
val dialogTitle = getString(R.string.newScp)
val positiveButtonTitle = getString(R.string.create)
val myDialog = AlertDialog.Builder(it)
val todoTitleEditText = EditText(it)
todoTitleEditText.inputType =
InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_WORDS
myDialog.setTitle(dialogTitle)
myDialog.setView(todoTitleEditText)
myDialog.setPositiveButton(positiveButtonTitle) { dialog, _ ->
uri = imageURI.toString()
val list = viewData(todoTitleEditText.text.toString(),uri,R.drawable.image,"SCP Name: ", "SCP Class", "Date Discovered: ", "Kill Count:" )
addToList(list)
dialog.dismiss()
ListItemCLickedu(list)
}
myDialog.create().show()
}
}
else{ Log.d("TESTING2", "THIS CODE DOES NOT RUN!")
}
}

Based on your code,i try this and works fine:
private lateinit var imageURI: Uri
companion object {
const val REQUEST_MEDIA = 101
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Log.d("TEST1", "FUN EXECUTED")
button.setOnClickListener {
showCreateTodoList()
Log.d("TEST2", "RECIEVING INPUT")
}
}
private fun showCreateTodoList() {
openGallery()
}
private fun openGallery() {
val gallery = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI)
startActivityForResult(gallery, REQUEST_MEDIA)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == RESULT_OK && requestCode == REQUEST_MEDIA) {
Log.d("TESTING", "THIS CODE RUNS")
imageURI = data?.data!!
// Use the Builder class for convenient dialog construction
val builder = AlertDialog.Builder(this)
builder.setMessage("Dummy Dialog Title")
.setPositiveButton("Ok",
DialogInterface.OnClickListener { dialog, id ->
// what you want to do on positive click
dialog.dismiss()
})
.setNegativeButton("Cancel",
DialogInterface.OnClickListener { dialog, id ->
// User cancelled the dialog
dialog.dismiss()
})
// Create the AlertDialog object and return it
builder.create().show()
}
}
Please check if you add permissions in your manifest file and also if you are in fragment check if activity in activity?.let is null. If so, try something getBaseActivity()?.let or applicationContext?.let and in there display your dialog.

Related

Why is In-app updates doesn't update the app as expected?

Following is the code inside my SplashActivity.kt. Whenever there is an update available, mostly it doesn't show at all, but I think that is not because of any mistake in my code but as I learned it takes some time to show the user about the new update. My concern now is that when it shows the in-app update screen, it goes off and the app continues to the next screen and it doesn't ask the user to update the app to continue using the app. Have I made a mistake?
#Suppress("DEPRECATION")
class SplashActivity : AppCompatActivity() {
private lateinit var binding: ActivitySplashBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySplashBinding.inflate(layoutInflater)
setContentView(binding.root)
callInAppUpdate()
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
Handler().postDelayed(
{
val currentUserID = FirestoreClass().getCurrentUserID()
if (currentUserID.isNotEmpty()) {
startActivity(Intent(this#SplashActivity, HomeActivity::class.java))
} else {
startActivity(
Intent(
this#SplashActivity,
LoginActivity::class.java
)
)
}
finish()
},
2500
)
}
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (data == null) return
if (requestCode == updateRequestCode) {
Toast.makeText(this, "Downloading", Toast.LENGTH_SHORT).show()
if (resultCode != RESULT_OK) {
Log.d("TAG", "update flow failed $resultCode")
}
}
}
private val updateRequestCode = 1612
private fun callInAppUpdate() {
val appUpdateManager = AppUpdateManagerFactory.create(this)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo, AppUpdateType.IMMEDIATE, this, updateRequestCode
)
}
}
}
}
EDIT:
I moved the postDelayed to the addOnSuccessListener, the fun callInAppUpdate() now look like the following.
private fun callInAppUpdate() {
val appUpdateManager = AppUpdateManagerFactory.create(this)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo, AppUpdateType.IMMEDIATE, this, updateRequestCode
)
}else{
Handler().postDelayed(
{
val currentUserID = FirestoreClass().getCurrentUserID()
if (currentUserID.isNotEmpty()) {
startActivity(Intent(this#SplashActivity, DashboardActivity::class.java))
} else {
startActivity(
Intent(
this#SplashActivity,
LoginWithPhoneNumberActivity::class.java
)
)
}
finish()
},
2500
)
}
}
}
You could achieve your behaviour like below:
class SplashActivity : AppCompatActivity() {
private val updateRequestCode = 1612
private lateinit var binding: ActivitySplashBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySplashBinding.inflate(layoutInflater)
setContentView(binding.root)
callInAppUpdate()
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (data == null) return
if (requestCode == updateRequestCode) {
Toast.makeText(this, "Downloading", Toast.LENGTH_SHORT).show()
if (resultCode != RESULT_OK) {
Log.d("TAG", "update flow failed $resultCode")
navigate()
}
}
}
private fun navigate(){
Handler().postDelayed(
{
val currentUserID = FirestoreClass().getCurrentUserID()
if (currentUserID.isNotEmpty()) {
startActivity(Intent(this#SplashActivity, DashboardActivity::class.java))
} else {
startActivity(
Intent(
this#SplashActivity,
LoginWithPhoneNumberActivity::class.java
)
)
}
finish()
},
2500
)
}
private fun callInAppUpdate() {
val appUpdateManager = AppUpdateManagerFactory.create(this)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo, AppUpdateType.IMMEDIATE, this, updateRequestCode
)
}
else {
navigate()
}
}
}
}
You have navigation logic inside postDelayed. You are explicitly navigating to new activity after 2500 ms. So the code is doing exactly what you wrote.
If you want to navigate after checking for the update then you probably should move navigation logic to addOnSuccessListener although it does seems like a hack too. Either way i wouldn't do this check in the splash screen but in some more "static" screen that does not have navigation on timer set

What is Error reading Sqlite database: Database 'LiveSqliteDatabaseId>?

Sorry for including this long code. I try to learn from the tutorial on youtube but the video tutorial lacks an explanation.Tutorial video use java, but i try to implement it for my kotlin app. but when i try to take a picture, i get this error:
Error reading Sqlite database: Database 'LiveSqliteDatabaseId(path=/data/data/com.example.b1/databases/google_app_measurement_local.db,name=google_app_measurement_local.db, connectionId=1) not found
Why i get this error? What is wrong with my code?
I also make TextView that can be clicked to sellect category but is doesn't work. it seems the categoryDialog() function in my code has a problem. Is this what causes the error above?
My code:
class AddProductActivity : AppCompatActivity() {
private val CAMERA_REQUEST_CODE:Int =200
private val STORAGE_REQUEST_CODE:Int =300
private val IMAGE_PICK_GALLERY_CODE:Int =400
private val IMAGE_PICK_CAMERA_CODE:Int =500
lateinit var cameraPermission: Array<String>
lateinit var storagePermission: Array<String>
lateinit var image_Uri:Uri
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_product)
cameraPermission= arrayOf(android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
storagePermission= arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
item_image.setOnClickListener{
showImagePickDialog()
}
tv_kategori.setOnClickListener{
categoryDialog()
}
tambahkan_barang.setOnClickListener{
inputData()
}
}
private lateinit var kategori: String
private lateinit var berat_sampah: String
private lateinit var deskripsi: String
private fun inputData(){
kategori=tv_kategori.text.toString().trim({it<=' '})
berat_sampah=et_berat_sampah.text.toString().trim({it<=' '})
deskripsi=et_deskripsi.toString().trim({it<=' '})
if(TextUtils.isEmpty(kategori)){
Toast.makeText(
this#AddProductActivity,
"Harap memilih kategori",
Toast.LENGTH_SHORT)
.show()
return
}
if(TextUtils.isEmpty(berat_sampah)){
Toast.makeText(
this#AddProductActivity,
"Harap mengisi berat sampah",
Toast.LENGTH_SHORT)
.show()
return
}
if(TextUtils.isEmpty(deskripsi)){
Toast.makeText(
this#AddProductActivity,
"Harap mengisi deskripsi singkat",
Toast.LENGTH_SHORT)
.show()
return
}
addProduct()
}
private fun addProduct(){
val timeStamp:String=""+System.currentTimeMillis()
if(image_Uri==null){
val hashMap:HashMap<String,String> = HashMap<String,String>()
hashMap.put("productId",timeStamp)
hashMap.put("productCategory",kategori)
hashMap.put("productWeight",berat_sampah)
hashMap.put("productDescription",deskripsi)
hashMap.put("productIcon","")
//hashMap.put("uid",""+firebaseAuth.uid)
}
}
private fun categoryDialog(){
val builder= AlertDialog.Builder(this)
builder.setTitle("Kategori Sampah").setItems(Constants.KATEGORI_BARANG){dialog,which ->{
val category= Constants.KATEGORI_BARANG[which]
tv_kategori.setText(category)
}}.show()
}
private fun showImagePickDialog(){
val options: Array<String> = arrayOf("Kamera","Gallery")
val builder= AlertDialog.Builder(this)
builder.setTitle("Pilih Gambar").setItems(options) { dialog, which ->
// put your logic in here
if(which==0){
if(checkCameraPermission()){
pickFromCamera()
}
else{
requestCameraPermission()
}
}
else{
if(checkStoragePermission()){
pickFromGallery()
}
else{
requestStoragePermission()
}
}
}.show()
}
private fun pickFromGallery(){
val intent= Intent(Intent.ACTION_PICK)
intent.setType("image/*")
startActivityForResult(intent,IMAGE_PICK_GALLERY_CODE)
}
private fun pickFromCamera(){
val contentValues= ContentValues()
contentValues.put(MediaStore.Images.Media.TITLE,"Temp_Image_Title")
contentValues.put(MediaStore.Images.Media.DESCRIPTION,"Temp_Image_Description")
image_Uri= contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues)!!
intent= Intent(MediaStore.ACTION_IMAGE_CAPTURE)
intent.putExtra(MediaStore.EXTRA_OUTPUT,image_Uri)
startActivityForResult(intent, IMAGE_PICK_CAMERA_CODE)
}
private fun checkStoragePermission(): Boolean{
val result :Boolean=ContextCompat.checkSelfPermission(this#AddProductActivity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)==(PackageManager.PERMISSION_GRANTED)
return result
}
private fun requestStoragePermission(){
ActivityCompat.requestPermissions(this,storagePermission,STORAGE_REQUEST_CODE)
}
private fun checkCameraPermission(): Boolean{
val result :Boolean=ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA)==(PackageManager.PERMISSION_GRANTED)
val result1 :Boolean=ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)==(PackageManager.PERMISSION_GRANTED)
return result && result1
}
private fun requestCameraPermission(){
ActivityCompat.requestPermissions(this,cameraPermission,STORAGE_REQUEST_CODE)
}
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
when (requestCode){
CAMERA_REQUEST_CODE->{
if(grantResults.size>0){
val cameraAccepted:Boolean=grantResults[0]==PackageManager.PERMISSION_GRANTED
val storageAccepted:Boolean=grantResults[1]==PackageManager.PERMISSION_GRANTED
if(cameraAccepted && storageAccepted){
pickFromCamera()
}
else{
Toast.makeText(
this#AddProductActivity,
"Akses Kamera dan Penyimpanan dibutuhkan",
Toast.LENGTH_SHORT)
.show()
}
}
}
STORAGE_REQUEST_CODE->{
if(grantResults.size>0){
val storageAccepted:Boolean=grantResults[0]==PackageManager.PERMISSION_GRANTED
if(storageAccepted){
pickFromGallery()
}
else{
Toast.makeText(
this#AddProductActivity,
"Akses Penyimpanan dibutuhkan",
Toast.LENGTH_SHORT)
.show()
}
}
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if(resultCode== RESULT_OK){
if(requestCode == IMAGE_PICK_GALLERY_CODE){
//img pick from gallery
//save picked img
image_Uri= data!!.getData()!!
//set IMG
item_image.setImageURI(image_Uri)
}
else if(requestCode==IMAGE_PICK_CAMERA_CODE){
item_image.setImageURI(image_Uri)
}
}
super.onActivityResult(requestCode, resultCode, data)
}
}
Turns out the problem was with the lamda. I'm following a tutorial with java language and when i try with kotlin i fail to manage the changes. I change my categoryDialog() function to:
private fun categoryDialog(){
val builder= AlertDialog.Builder(this)
builder.setTitle("Kategori Sampah").setItems(Constants.KATEGORI_BARANG){dialog,which ->
val category= Constants.KATEGORI_BARANG[which]
tv_kategori.setText(category)
}.show()
}

ImageView doesn't display Image from gallery

I want to pick image from gallery, I added the READ_EXTERNAL_STORAGE permission to Manifest, but it doesn't work fine. It take path uri of image but doesn't show it. Only rectangle with good proportions (screen and code below)
class NewRestaurantFragment : Fragment(R.layout.fragment_new_restaurant) {
companion object {
private const val TAG = "NewRestaurantFragment"
private const val GET_IMAGE_REQUEST_CODE = 2137
}
private lateinit var ivPhoto: ImageView
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
ivPhoto = view.findViewById(R.id.iv_photo)
ivPhoto.setOnClickListener {
selectPhoto()
}
}
private fun selectPhoto() {
val intent = Intent()
intent.apply {
type = "image/"
action = Intent.ACTION_PICK
}
startActivityForResult(intent, GET_IMAGE_REQUEST_CODE)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == GET_IMAGE_REQUEST_CODE && resultCode == RESULT_OK) {
val uri = data!!.data
ivPhoto.setImageURI(uri)
}
}
}

Object does not exist at location android studio Kotlin

I wanna store an image in firebase storage but i got an warning message when running "Object does not exist at location", I don't know where is my mistake, already trying search old answer but all of them in java not kotlin.
class Activity2 : AppCompatActivity() {
private var curFile: Uri? = null
private val imageRef = Firebase.storage.reference
private val REQUEST_CODE_IMAGE_PICK = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity2)
//an image view to select and image inside phone storage
ivfoto.setOnClickListener {
Intent(Intent.ACTION_GET_CONTENT).also {
it.type = "image/*"
startActivityForResult(it, REQUEST_CODE_IMAGE_PICK)
}
}
//btn for upload image to storage
btnupload.setOnClickListener {
uploadImageToStorage("Myimages")
}
}
//function to upload an image to firebase
private fun uploadImageToStorage(filename: String) = CoroutineScope(Dispatchers.IO).launch {
try {
curFile?.let {
imageRef.child("images/$filename").putFile(it).await()
withContext(Dispatchers.Main) {
Toast.makeText(
this#Activity2, "Foto anda telah dipilih",Toast.LENGTH_LONG).show()
}
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
Toast.makeText(this#Activity2, e.message, Toast.LENGTH_LONG).show()
}
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_IMAGE_PICK) {
data?.data?.let {
curFile = it
ivfoto.setImageURI(it)
}
}
}
}
Here is the error message,its on the device,already run in physical device and emulator but the error is the same

Multiple results from activity to fragment

I've got a question about results/callback from activities to fragments.
Until now I have a fragment which calls a camera activity to scan QR Codes. So I start the activity from the fragment with startActivityForResult. If a QR Code is successfully scanned I get a callback Intent which is handled in onActivityResult.
This works perfectly.
Now I want to handle multiple scanns. In detail that means, that every successfully scan should call the onActivityResult function without closing the activity. The problem which I got at this point is, that onActivityResult is only called if I call finish() in the camera activity.
So my question is, how can I call onActivityResult multiple times with or without calling finish() but without closing the activity? Or is there another way to handle callbacks from activities to fragments?
This is my fragment code:
class ScanFragment : Fragment() {
private val CHECKIN_CODE = 0
private val CHECKOUT_CODE = 1
companion object {
fun newInstance(): LeadScanFragment = LeadScanFragment()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_lead_scan, container, false)
view.checkin.setOnClickListener {view ->
val intent = Intent(activity, CodeScannerActivity::class.java)
startActivityForResult(intent, CHECKIN_CODE)
}
view.checkout.setOnClickListener {view ->
val intent = Intent(activity, CodeScannerActivity::class.java)
startActivityForResult(intent, CHECKOUT_CODE)
}
return view
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == CHECKIN_CODE) {
if (resultCode == Activity.RESULT_OK) {
val returnString = data!!.getStringExtra("hash")
Log.d("scaned in", returnString)
}
}
if (requestCode == CHECKOUT_CODE) {
if (resultCode == Activity.RESULT_OK) {
val returnString = data!!.getStringExtra("hash")
Log.d("scaned out", returnString)
}
}
}
}
And this is the camera activity code:
class CodeScannerActivity : AppCompatActivity() {
private val requestCodeCameraPermission = 1001
private lateinit var cameraSource: CameraSource
private lateinit var detector: BarcodeDetector
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_code_scanner)
if (ContextCompat.checkSelfPermission(this#CodeScannerActivity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
askForCameraPermission()
} else {
setup()
}
}
private fun setup() {
detector = BarcodeDetector.Builder(this#CodeScannerActivity).build()
cameraSource = CameraSource.Builder(this#CodeScannerActivity, detector).setAutoFocusEnabled(true).build()
cameraSurfaceView.holder.addCallback(surfaceCallback)
detector.setProcessor(processor)
}
private fun askForCameraPermission() {
ActivityCompat.requestPermissions(this#CodeScannerActivity, arrayOf(Manifest.permission.CAMERA), requestCodeCameraPermission)
}
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if(requestCode == requestCodeCameraPermission && grantResults.isNotEmpty()) {
if(grantResults[0] == PackageManager.PERMISSION_GRANTED) {
setup()
} else {
Toast.makeText(applicationContext, "Permission denied!", Toast.LENGTH_SHORT).show()
}
}
}
private val surfaceCallback = object : SurfaceHolder.Callback {
override fun surfaceCreated(surfaceHolder: SurfaceHolder?) {
try {
cameraSource.start(surfaceHolder)
} catch (exception: Exception) {
Toast.makeText(applicationContext, "Something went wrong", Toast.LENGTH_SHORT).show()
}
}
override fun surfaceChanged(p0: SurfaceHolder?, p1: Int, p2: Int, p3: Int) {
}
override fun surfaceDestroyed(p0: SurfaceHolder?) {
cameraSource.stop()
}
}
private val processor = object : Detector.Processor<Barcode> {
override fun release() {
}
override fun receiveDetections(detections: Detector.Detections<Barcode>?) {
val intent = Intent()
if(detections != null && detections.detectedItems.isNotEmpty()) {
val qrCodes: SparseArray<Barcode> = detections.detectedItems
val code = qrCodes.valueAt(0)
intent.putExtra("hash", code.displayValue)
setResult(Activity.RESULT_OK, intent)
finish()
} else {
setResult(Activity.RESULT_CANCELED, intent)
finish()
}
}
}
}
receiveDetections inside the processor in the lower area of the camera activity code is where the callback Intent is send back to onActivityResult.
You could have the scanner Activity send a local broadcast Intent to forward "results" to the calling Fragment. The Fragment (or its hosting Activity) should set a listener to listen for the broadcast "results". In this way you could perform multiple scans and send each result back to the underlying Activity.

Categories

Resources