Questions tagged onactivityresult

Explore the latest questions and answers asked by our top developers.

Customizing call back for ActivityResultContracts.TakePicture() to get passed uri as well

The following are the methods i have declared for capturing image from Android 11 version supporting app. I want to cutomize the call back to get the input uri, instead of just getting a boolean status. As of now the following is methods, which are working fine. private final ActivityResultLauncher<Uri> takePicture = registerForActivityResult(new ActivityResultContracts.TakePicture(), this::onTakePictureResult); […]

pick only documents types from storage using activity result API

I need to make the user able to pick only documents types (ex: pdf, docs, xls) from phone storage using the new Activity Result API, but the problem is that when I launch the contract like the following code private val getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? -> … } fun pickDocument() = getContent.launch("*/*") user […]

Activate GPS and required permission

I try to check if GPS is enable. If not I try to open in programatically with next code: private void getDeviceLocation(){ mLocationRequest = LocationRequest.create(); mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { fusedLocationProviderClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper()); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(mLocationRequest); LocationSettingsRequest locationSettingsRequest = builder.build(); SettingsClient settingsClient = LocationServices.getSettingsClient(mContext); settingsClient.checkLocationSettings(locationSettingsRequest); Task<LocationSettingsResponse> result; result […]

By Ion din Vale
Published
Categorized as android-gps, android-studio, java, onactivityresult

Get orignal path of content URI to upload image to FTP server

I want to upload image to FTP server without using read and write permission. I have been successful in getting content uri but unable to find orignal path of image to get input stream. As i am getting uri content://com.android.providers.media.documents/document/image%3A1537 but my orignal path is different which is internal storage/DCIM/Camera/IMG_20211026_11232.jpg i am getting using new […]

Scanner Android Studio

Good morning, I have a question with this code, I explain, I have 2 buttons, one to scan codes of type "EAN-13" and another of type "CODE-39", what I want to do is that the onActivityResult differentiates when it receives a type of code perform an action and do another action with the other type […]

By Juan Morales
Published
Categorized as android, barcode-scanner, java, onactivityresult, scanning

Keep asking the user to turn on the BT, until he does

In Android Studio: How can I ask the user to activate the BT and wait for a response later? My goal is to ask the user to turn on the BT, if he denies, show a Toast error and keep asking until he accepts I tried private val REQUEST_ENABLE_BT = 0 … Then inside onCreate […]

By Sacci Spacci
Published
Categorized as android, android-bluetooth, android-studio, onactivityresult

How to get if user enable the any permission from settings page of app in android

How to get if user enable the permission from setting page of application For Example Consider a app has permission activity. In permission activity it show location permission default dialog. when user allow the permission I proceed the further steps. When user denied the permission, Then I show the permission dialog again. When user permanently […]

call onActivityResult() repeatedly

So me and my group are having a project in school. We decided to make an app. The app is gonna work like this: The user can press on the screen and the app will ask what the user want’s to do. The user then can says some different things, like (Battery, vibration, and more). […]

By Inomie
Published
Categorized as android, java, onactivityresult

RunTimeException cameraApp

I try to implement a simple camera app, that take a picture using default camera app and displays it in a imageview, please see the code below: public class MainActivity extends AppCompatActivity { public static final int CAMERA_PERM_CODE = 101; public static final int CAMERA_REQUEST_CODE = 102; ImageView img; Button btncamera, btngallery; String currentPhotoPath; File […]

By mikery
Published
Categorized as android, android-camera, onactivityresult

Attempting to launch an unregistered ActivityResultLauncher

Sometimes I’m getting this IllegalStateException, and it says that you must ensure the ActivityResultLauncher is registered before calling launch(). But there is no method to check if ActivityResultLauncher is registered. How can I solve this and why this may happen? Also it’s not clear when to call unregister() method, any examples? Source: Android Questions

By user1242192
Published
Categorized as android, android-activity, onactivityresult
1 2 3 12

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq