I am using the latest Phone Number Hint API library, provided by Google Play Services, for requesting phone number as hint. Here is my code :
implementation 'com.google.android.gms:play-services-auth:20.3.0'
implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
private val phoneNumberHintIntentResultLauncher =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result ->
try {
val phoneNumber =
Identity.getSignInClient(requireContext()).getPhoneNumberFromIntent(result.data)
Log.d("PhoneNumberRetrieved", phoneNumber)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun requestPhoneNumberHint() {
val request = GetPhoneNumberHintIntentRequest.builder().build()
Identity.getSignInClient(requireContext())
.getPhoneNumberHintIntent(request)
.addOnSuccessListener { taskResult ->
phoneNumberHintIntentResultLauncher.launch(
IntentSenderRequest.Builder(
taskResult.intentSender
).build()
)
}
.addOnFailureListener {
it.printStackTrace()
}
}
Above code is working fine on devices with Android version less than 12. But it is not working properly on devices with Android 12. I have tried on two different devices and here are the results*:
Realme narzo 50a** - failureListner is invoked with this message
16: API is disabled
Samsung Galaxy M32 - failureListner is invoked with this message
16: No phone number is found on this device. Even though the device has valid numbers available.
* NOTE : The old deprecated Hint Request API is working properly on both devices giving expected results i.e. showing device phone numbers in a pop-up.
** IMPORTANT : Same code worked properly on this device on day 1 of my implementation i.e. it showed the available phone numbers on a bottom sheet. But on the next day, for unknown reasons, it started giving above mentioned result. Although I made no changes in my code.
If anyone else has faced this issue or have any information regarding this, please do share you thoughts.
Related
When i was trying to developing GPS tracking Android APP with Google Activity Recognition Transition API, I had a API-working stop issue.
I thought that it is a problem of device-model compatible but not sure exactly about it because it occurs very irregulary and dose not process any error log for it.
If someone has know about the solution, please give me some good advise for it.
I really appreciate for hearing some good advise to solve this problem.
Android device information:
SDK_INT : 31
RELEASE : 12
BRAND : samsung
An explanation for when not working Transition API:
First of all, Transition API is working good under to device model ‘Android 12’.
But when I try to test on 12 or over version, the API-stoping problem is occurs in 1 days to 1 week.
Also the problem dose not make any error log to find and analysis the exact problem.
Stoped Google Activity Recognition Transition API will work when reboots the device, but not work with re-installation.
Other APP that using Transition API having no problem while my APP is not working.
Also, other APP and my APP can be not working when the Transition API is stopped.
3.Installation in test-phone
Build the Apk or generate a Signed Build generate Signed Build or Apk and upload the
The same problem has occurred when try to test with the uploaded internal version of google ‘Play Store’
4.Sorce explanation
My app has one foregound service is runing.
When the APP is executed first time, the Transition API is runing that insideof the foreground service.
How to activate the API:
val intent = Intent(ACTIVITY_RECOGNITION_EVENT)
val pendingIntent = PendingIntent.getBroadcast(context, 0, intent, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
} else {
PendingIntent.FLAG_UPDATE_CURRENT
})
...
val activityRecognitionClient = ActivityRecognition.getClient(context)
// val interval = 20 * 1000L
val interval = 3 * 60 * 1000L
val task = activityRecognitionClient.requestActivityUpdates(interval, pendingIntent)
task.addOnSuccessListener {
...
}
task.addOnCompleteListener {
...
}
task.addOnCanceledListener {
...
}
task.addOnFailureListener {
...
}
// createRequest skip
val activityRecognitionClient = ActivityRecognition.getClient(context)
val task = activityRecognitionClient.requestActivityTransitionUpdates(
createRequest(),
pendingIntent
)
task.addOnSuccessListener {
...
}
task.addOnCanceledListener {
...
}
task.addOnFailureListener {
...
}
task.addOnCompleteListener {
...
}
// In receiver, it work like this:
private val transitionsReceiver = object: BroadcastReceiver() {
override fun onReceive(_context: Context, intent: Intent) {
if (ActivityRecognitionResult.hasResult(intent)) {
val result = ActivityRecognitionResult.extractResult(intent)
...
}
else if (ActivityTransitionResult.hasResult(intent)) {
val result = ActivityTransitionResult.extractResult(intent)
...
}
}
}
val intentFilter = IntentFilter()
intentFilter.addAction(ACTIVITY_RECOGNITION_EVENT)
context.registerReceiver(transitionsReceiver, intentFilter)
Is there any one having this problem?
I’m still working on this problem but can not find the reason of the Google Activity Recognition Transition API stopping.
I would like to know any advice or hint for solving this and appreciate it for your comment.
Am I miss something or having wrong point?
I'm having the same issue as you. It happens on both Sampling API and Transition API. We noticed on multiple Samsung devices but not sure if it is happening on other. I opened a issue on tracker
I'm having a similar issue. Currently what I've found is that when my app can retrieve Sensor.TYPE_SIGNIFICANT_MOTION then Activity Transitions updates come in correctly, but then at some point, sensor is null in my logs and I receive no updates whatsoever. Feels to me that OS blocks this sensor at some point (allows it to fall in deep sleep) and then there's no coming back. :(
I am trying to use the AppUpdateManager class to check to see if an update is available, however I am seeing different results depending on what type of Android device that I use. When I make the call with a Pixel 6 Pro, it returns an update is available, but when I tried the same code on a couple of Samsung devices, it returns not available. Below is a sample of the code that I am using. Does anyone have an idea of why this behavior might happen between devices?
fun checkForUpdates(activity: Activity) {
val appUpdateManager = AppUpdateManagerFactory.create(activity)
appUpdateManager?.appUpdateInfo.addOnSuccessListener {
val updateAvailability = it.updateAvailbility()
// Pixel 6 Pro -> Returns UPDATE_AVAILABLE
// Samsung Galaxy S21 -> Returns UPDATE_NOT_AVAILABLE
}
}
I would expect any device I try to return the same value when I do an update check.
When using the OnReceiveContentListener I followed along with the guide here. I also looked at the example project they reference. From my understanding the way it works is that if I enter the code
val editTextOnReceiveContentListener =
androidx.core.view.OnReceiveContentListener { editText, contentInfoCompat ->
val split = contentInfoCompat.partition { it.uri != null }
val uriContent = split.first
val remaining = split.second
/** Process uriContent here... **/
//return remaining
remaining
}
ViewCompat.setOnReceiveContentListener(
myEditText,
arrayOf("image/gif", "image/png"),
editTextOnReceiveContentListener
)
Then when 'remaining' is null the app will NOT show the user "AppName doesn't support image insertion here". And most of the time it seems to be work just as I expect.
However if I use the 'Cold Boot Now' option for starting the emulator (and other times occasionally) then the first gif that is entered will still display that image insertion is not supported here. Everything else seems to work fine except it shows the error. This happens even though the log shows that 'remaining' is null. I tested it on emulator devices Nexus 5 and Pixel 2 for API 29 and 31.
My question is, is this something that I should be concerned about and/or can fix in some way?
I've implemented Android client using Twilio SDK to do video calls. It works as expected but I found an edge case which I can not figure out how to fix. Here is essence of video call code:
val connectionOptions = ConnectOptions.Builder(accessToken)
.audioTracks(listOf(audioManager.getLocalAudioTrack()))
.roomName(roomId)
.build()
val roomListener = RoomListener()
Video.connect(androidContext, connectOptions, roomListener)
class RoomEventListener : Room.Listener {
override fun onParticipantDisconnected(room: Room, remoteParticipant: RemoteParticipant) {
// remove participant from the screen, unsubscribe from events
}
override fun onConnectFailure(room: Room, twilioException: TwilioException) {
exitScreenWithErrorMessage(R.string.video_consult_room_connection_error)
}
override fun onReconnected(room: Room) {
_shouldShowReconnectionActivity.value = false
}
override fun onParticipantConnected(room: Room, remoteParticipant: RemoteParticipant) {
onRemoteParticipantConnected(remoteParticipant)
}
override fun onConnected(room: Room) {
_shouldShowConnectionActivity.value = false
this#VideoCallViewModel.room = room
room.remoteParticipants.forEach { onRemoteParticipantConnected(it) }
determineMainParticipant()
onLocalParticipantConnected(room)
}
override fun onDisconnected(room: Room, twilioException: TwilioException?) {
exitVideoConsultScreen()
}
override fun onReconnecting(room: Room, twilioException: TwilioException) {
_shouldShowReconnectionActivity.value = true
}
}
Test case:
Bob joins video call using Android phone
Jane joins same video call from any device (iOS, web, Android)
When Jane loses connection (i.e. turn off internet)
Then Bob sees for 1-2 minutes reconnecting (programmatically "onReconnecting" callback triggered)
[Actual] And Bob disconnected from room (in logs I see Media connection failed or Media activity ceased with error code 53405)
[Expected] Bob stays at the room.
I'm not sure why under such conditions Android client has been disconnected (We tested it on different devices with Android 8/9).
Couple more details:
If Jane exits room using "End call" button (so room.disconnect() code from Twilio SDK has been called) then Bob stays in the room.
When Bob using iOS device (implementation of iOS and Android quite the same) then described use case passes.
We tried 5.0.1 and 5.1.0 version of com.twilio:video-android library.
I noticed Known Issue for Android Twilio Video library in Release notes and I'm not sure can it affects described use case or not:
Unpublishing and republishing a LocalAudioTrack or LocalVideoTrack might not be seen by Participants. As a result, tracks published after a Room.State.RECONNECTED event might not be subscribed to by a RemoteParticipant.
I opened issue on twilio github repo https://github.com/twilio/video-quickstart-android/issues/454 - and this is expected behaviour for twilio video sdk 5.x+. Both for Android and iOS sdks.
After flashing my Nexus 5 to the Android 5.0 preview release hammerhead-lpx13d, the OS reports that it no longer supports Bluetooth LE advertising. If you call:
((BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE))
.getAdapter().getBluetoothLeAdvertiser()
always returns null. In addition, the new method:
((BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE))
.getAdapter().isMultipleAdvertisementSupported()
always returns false
The first method used to return a valid object on the first Android L preview release for the Nexus 5 back in June. It no longer does, after flashing the latest update.
Does anybody see otherwise?
EDIT: This has been reproduced by at least one person, who opened an issue with Google here: https://code.google.com/p/android-developer-preview/issues/detail?id=1570
Unfortunately, the official answer from Google is no, the Nexus 5 no longer supports advertising.
We introduced BLE peripheral mode in Android 5.0 Lollipop. Nexus 6 and
Nexus 9 are the first two production Nexus devices that support BLE
peripheral mode. Due to hardware chipset dependency, older Nexus
devices (4/5/7) will not have access to the feature on Lollipop.
See Comment #52 on issue 1570 by danielho...#google.com: BLE advertise mode not working
https://code.google.com/p/android-developer-preview/issues/detail?id=1570
That said, I have confirmed that advertising is supported by the Nexus 9 tablet. See here for details: http://developer.radiusnetworks.com/2014/11/18/beacon-transmission-with-android-5.html
This is not full a solution, but a proposed work-around posted by mattprec on Google Code. It allows you to get a BluetoothLeAdvertiser instance by calling the private constructor rather than using the public API. Unfortunately, reports of testing on a Nexus 5 and a Nexus 7 2013 edition say that even after you get an instance you can't use the object to make advertisements come out. Also, be warned that even if you can get it to work, it might break on any minor code release of Android because it is using a non-public API.
For the record, here's the code snippet copied from that page:
private static BluetoothLeAdvertiser getAdvertiserHack(BluetoothAdapter adapter) {
try {
Class<? extends BluetoothAdapter> adapterClass = adapter.getClass();
Field advertiserField = adapterClass.getDeclaredField("sBluetoothLeAdvertiser");
advertiserField.setAccessible(true);
Object advertiser = advertiserField.get(adapter);
if (advertiser == null) {
Field bluetoothManagerServiceField = adapterClass.getDeclaredField("mManagerService");
bluetoothManagerServiceField.setAccessible(true);
Object bluetoothManagerService = bluetoothManagerServiceField.get(adapter);
Constructor<?> constructor = BluetoothLeAdvertiser.class.getDeclaredConstructor(
bluetoothManagerServiceField.getType());
constructor.setAccessible(true);
advertiser = constructor.newInstance(bluetoothManagerService);
advertiserField.set(adapter, advertiser);
}
return (BluetoothLeAdvertiser) advertiser;
} catch (Exception e) {
return null;
}
}
That said, I have confirmed that advertising is supported by the Nexus
9 tablet. See here for details:
http://developer.radiusnetworks.com/2014/11/18/beacon-transmission-with-android-5.html
QuickBeacon app is working fine on Nexus 9. In app there is a Beacon Format option.#davidgyoung Could you give exact String for BeaconParser to make this library transmit in iBeacon format?
UPDATE:
Related question up to android-beacon-library/BLE Android SDK. Is there possibility - without calling startAdvertising method - to check if there is advertising service running in background?
UPDATE:
Recording to this : https://code.google.com/p/android-developer-preview/issues/detail?id=1570#c52
Now only Nexus 6 and Nexus 9 supports BLE Peripheal Mode in Android 5.0
UPDATE:
I work on Nexus 5 Android 5.0 build number LPX13D
according to this https://stackoverflow.com/a/26611779/1906420
After implementig your workaround bluetoothAdvertiser is not null. Calling startAdvertising from bluetoothAdvertiser
bluetoothAdvertiser.startAdvertising(settingsBuilder.build(), dataBuilder.build(), advertiseCallback);
where
private AdvertiseCallback advertiseCallback = new AdvertiseCallback() {
#Override
public void onStartSuccess(AdvertiseSettings settingsInEffec) {
}
#Override
public void onStartFailure(int result) {
if (result == ADVERTISE_FAILED_DATA_TOO_LARGE) {
Log.d(TAG, "Failed to start advertising as the advertise data to be broadcasted is larger than 31 bytes.");
}
else if(result == ADVERTISE_FAILED_TOO_MANY_ADVERTISERS){
Log.d(TAG, "Failed to start advertising because no advertising instance is available.");
}
else if(result == ADVERTISE_FAILED_ALREADY_STARTED){
Log.d(TAG, "Failed to start advertising as the advertising is already started.");
}
else if(result == ADVERTISE_FAILED_INTERNAL_ERROR){
Log.d(TAG, "Operation failed due to an internal error.");
}
else if(result == ADVERTISE_FAILED_FEATURE_UNSUPPORTED){
Log.d(TAG, "This feature is not supported on this platform.");
}
else {
Log.d(TAG, "There was unknown error.");
}
}
};
always give callback onStartFailure with error code 5 ( ADVERTISE_FAILED_FEATURE_UNSUPPORTED )