Skip to content
Advertisement

Tag: android

Wear OS onKeyDown not firing for Ticwatch E

I have a Ticwatch E connected using ADB and I’m viewing the logcat. There is only one button on this device but when I press it, my onKeyDown method does not fire. I’ve been reading the Android documentation on Physical buttons, and have followed what they have specified. Here is my code: My stackoverflow searching uncovered this: Android wear activity

How to handle the Usb Permission Dialog Event on android when using the “device filter” solution?

I’m trying to handle the event when a user presses “ok” or “cancel” on the automatic permission dialog presented when I connect a “known” USB device to the android phone. I’m using the android.usb.host library and can send and receive between the android phone and the device. Futhermore do I handle the “USB_DEVICE_ATTACHED” and “USB_DEVICE_DETACHED” using a BroadcastReceiver without any

Incorrect displaying items in RecyclerView while scrolling

Could you please assist in following issue: I have incorrect displaying items in my messenger app. My layout for items: My layout for dialog activity: Class DialogActivity Adapter class In this place I check user name. If user name is my name then I set message and visible to holder.messageMyMessage. Else I set message and visible to holder.messageYourMessage. But sometimes

How to access “types” dynamically with java?

I don’t know what types.DocumentType is, but I’m doing an integration of an sdk and I created a cordova plugin. the import from the sdk is like this: Can I somehow pass RG_FRENTE dynamically as it is done in javascript? Something like: Answer This solution is only if DocumentType is enum class like below. You can directly get by the

Unable to fetch unread messages from SMS inbox

I have successfully retrieved all messages from inbox but I want only unread messages . I have also apply in the query as read=0 which gives unread SMS but it can’t retrive unread messages it retrieves all messages. Answer Change your query arguments like this You are passing selection where clause for read = 0 in projections instead of where

How to set the width and height of a layout in Android?

I have this ConstraintLayout: lateinit var myConstraintLayout: ConstraintLayout I try to set its width and height to match its parent via code, like this: But I get error androidx.constraintlayout.widget.ConstraintLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams Why? How do I fix this? Answer The LayoutParams need to be the LayoutParams type of the parent ViewGroup. It is the parent ViewGroup that actually

Merging 2 regex that allow only English and Arabic characters

I have a string and I want to remove any other character such as (0..9!@#$%^&*()_., …) and keep only alphabetic characters. After looking up and doing some tests, I got 2 regexes formats: This should return “hello مرحبا ok”. But of course, this will return an empty string because we’re removing any non-Latin characters in the first regex then we

Advertisement