1,969 questions
3 votes
1 answer
128 views
Why does gathering the app list from PackageManager & tapping any one cause the UI to freeze?
I'm developing an Android app that gathers a list of currently installed apps, both system & user-installed, and displays them on screen via LazyColumn using a Card composable. And when the user ...
0 votes
0 answers
40 views
What does this@class mean in Kotlin?
I see several examples, such as in this sample code in the Android dev documentation or this blog post, which suggests that the way to get an Activity context is to use the syntax this@MainActivity. ...
-1 votes
1 answer
41 views
how do a Context in Android
i m french and my english is not good,so i use google to translate,sorry for mistakes I've been stuck on a problem for quite some time here you go: I'm looking to make a small application that makes ...
1 vote
0 answers
52 views
Android Hilt pass Activity/intentExtras in Singleton Provide function
I'm new to Hilt/Dagger. I have an existing project with a Singleton, and I need a parameter from the caller app stored in intent extras: @Module @InstallIn(SingletonComponent::class) class MyModule { ...
0 votes
1 answer
35 views
stale preferences in WallpaperService
I'm a beginner in Android development. I'm trying to build a simple live wallpaper app, inspired by https://github.com/cyunrei/Video-Live-Wallpaper. One of the modifications I want to make is to not ...
1 vote
0 answers
142 views
Activity Context VS Activity VS Activity Scoped Injection in Hilt
I have some questions regarding Hilt library based on this article I have read : When (and When Not) to Pass the Activity Context in Android Why we should inject Context instead of activity object in ...
0 votes
1 answer
33 views
Sometimes context.startActivity(intent) not working in a class that extends WebSocketServer in Android
I have a class that extends WebSocketServer and waits for a request from the client application and if a message arrives, it should run an activity. The code below shows how this works. Note that the ...
0 votes
1 answer
255 views
Per App language android - android 13 . Context - getString
val context = appContext context.getString(key) is returning string in default language of system in android 12 , while it is returning string in selected language in android 13. Is there any ...
3 votes
2 answers
2k views
Android Kotlin - requireContext() throws IllegalStateException inside Android Fragment's onViewCreated
I am dealing with IllegalStateException crashes pertaining to the usage of getString in onViewCreated; looking at the stack trace this goes back through getResources into requireContext, which throws ...
0 votes
2 answers
133 views
How to use context in a RecyclerView adapter for SharedPreferences? [duplicate]
I have a RecyclerView adapter for displaying a list of movies. I need to use the context to initialize the genrePreferences variable in my adapter. Where is the appropriate place in the adapter's ...
0 votes
0 answers
18 views
Function does not work in MainActivity, but works in TextRecognizerActivity [duplicate]
I have a recogniseText() function which does text recognition using google ML Kit, placed in TextRecognizerActivity. Initially, I received an image from gallery in MainActivity.kt, and passed it with ...
3 votes
0 answers
894 views
How to recreate/reinit/restart hilt components in Android?
I'm working on an app that allows you to change the language locally. To make this work without having to restart the app, I'm using the ContextWrapper on the BaseActivity, where I assign the language ...
-1 votes
1 answer
103 views
What type of context should I use in this case and why?
I am using the following function in one of my activities of my app: public static float convertDpToPixel(float dp, Context context){ return dp * ((float) context.getResources().getDisplayMetrics()...
1 vote
2 answers
7k views
error: @Composable invocations can only happen from the context of a @Composable function
would like to start TimerView() in onClick - TimerView is a text composable but the above mentioned error appears - both are marked composables Composable fun LosB(BLY: String, YArray: ArrayList<...
0 votes
1 answer
91 views
getContext() crashes my App when calling update RecyclerView function?
my app crashes all the time, when I want to access a specific fragment. The error is: FATAL EXCEPTION: main Process: com.akstudios.kindergarten, PID: 15680 java.lang.NullPointerException: Attempt to ...