Questions tagged [android-reflection]

Use this tag for questions about using reflection specifically on Android

12 questions
10
votes
2 answers

How to avoid a NoClassDefFoundError: android/os/PersistableBundle on pre-L?

I use the TinyBus library to dispatch events in my app. MinSDK is 15, compile SDK is 23. On pre-21 devices, I'm facing the issue which seems to affect many apps that use reflection. As soon as I try to register on the bus in my base Activity class…
Droidman
  • 11,485
  • 17
  • 93
  • 141
4
votes
1 answer

How to create a callback using reflection in android?

I am trying to access a method using reflection and one of the parameter is a callback. The callback type is generic interface of different class type. These classes are @SystemApi can be accessed by reflection. Here is the class I am working with…
Prabhakaran
  • 1,264
  • 2
  • 20
  • 47
2
votes
1 answer

Reflection on Jetpack Compose

Currently, I’m creating a new SDK that contains sensitive fields that shouldn’t be read by the consumers (Think Credit Card Number field) and I’m using Jetpack Compose to create the forms, my question is, is it possible to do a reflection on Jetpack…
2
votes
0 answers

How can i get a link to a running Activity of third-party application with reflection

I need to get a link to a running Activity of third-party application. Can anyone help me? I analyzed the android source code and i know that any activity has a PhoneWindow instance. Maybe this instance will be stored somewhere after creation... I…
1
vote
1 answer

Ignore Developer's Settings Animation Scale in Android

My app relies heavily on animations to work, and when their speed is changed in the developer's options, the whole app breaks and stops working. I've been researching ways of ignoring the developer's settings and forcing the animations to run as…
1
vote
3 answers

android kotlin - are Function References slow due to reflection?

Reflection is suppose to be a bit time consuming on android. so i was wondering given a function reference like this: fun isOdd(x: Int) = x % 2 != 0 val numbers = listOf(1, 2, 3) println(numbers.filter(::isOdd)) is ::isOdd call an unnecessary…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
1
vote
2 answers

java.lang.reflect.InvocationTargetException while implementing Room Android

@Dao interface MyStuffDao { @Query("SELECT * FROM mystuff WHERE mid = :mid") fun selectByMid(mid: Long): ArrayList @Insert fun insertMyStuff(mid: Long, name: String) @Delete fun deleteMyStuffName(mid: Long, name:…
c-an
  • 3,543
  • 5
  • 35
  • 82
1
vote
0 answers

How to find out why a reflection call freezes the app

I detected an issue that on the nexus 5x with android 8.1 and security patch from august calling a method by reflection freezes the app, this same call works on 10 other devices with android 8.0, android 7.1.1 etc. Is it possible to find out what is…
David
  • 3,971
  • 1
  • 26
  • 65
0
votes
0 answers

NoSuchMethodException is throwing when trying to access getActivePasswordQuality() method of LockPatternUtils class

I want to get access to com.android.internal.widget.LockPatternUtils class object using reflection and want to know the Lock method user has set in Android device. I am using below code for that : private fun getAuthenticationMethodType() : Int…
Kushal
  • 8,100
  • 9
  • 63
  • 82
0
votes
1 answer

Get OnTouchListener object from View by reflection

I need modify onTouch action on same View. So I needed in field mOnTouchListener that stored at static class ListenerInfo in public class View I try this: Field onTouchListenerField =…
Nikolay
  • 344
  • 1
  • 15
0
votes
1 answer

Android override private method by reflection

Hello I have class with private method, and I need override it by reflation. I see many examples fro change private fields, or call private methods, but I don't found any override example. I have this code public class TestClass { public void…
Nikolay
  • 344
  • 1
  • 15
0
votes
1 answer

Iterate Fields of Fields continuously with reflection

Please avoid giving answers in Kotlin only and higher than Android 21. I'm trying to build an API parser that makes use of class hierarchy logic to represent the API hierarchy itself. With this structure I am able to parse the API in an…
Shadow
  • 4,168
  • 5
  • 41
  • 72