Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
130 views

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 ...
Ryan Barillos's user avatar
0 votes
0 answers
40 views

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. ...
BobDoolittle's user avatar
  • 1,892
-1 votes
1 answer
44 views

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 ...
vulcain1972's user avatar
1 vote
0 answers
52 views

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 { ...
ocramot's user avatar
  • 1,411
0 votes
1 answer
35 views

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 ...
bmurauer's user avatar
  • 1,339
1 vote
0 answers
147 views

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 ...
Nadin Martini's user avatar
0 votes
1 answer
33 views

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 ...
behnam karimi's user avatar
0 votes
1 answer
256 views

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 ...
Jithin Murali's user avatar
3 votes
2 answers
2k views

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 ...
MajinKenn's user avatar
  • 109
0 votes
2 answers
134 views

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 ...
İbrahim Uyar's user avatar
0 votes
0 answers
18 views

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 ...
Yahya Abdul Majeed's user avatar
3 votes
0 answers
894 views

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 ...
Deneb Chorny's user avatar
-1 votes
1 answer
103 views

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()...
sacacorchos's user avatar
1 vote
2 answers
7k views

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<...
VFarkas2023's user avatar
0 votes
1 answer
91 views

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 ...
EXTSY's user avatar
  • 59
1 vote
0 answers
520 views

I'm writing unit tests for a use case that basically creates a file with the contents of an InputStream. However, with the lines: val path = context.filesDir.path + "/issues.csv" val fos = ...
noloman's user avatar
  • 12.1k
0 votes
2 answers
38 views

I have MainActivity.kt with passing an activity context to MyObj-class: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(...
Ihor Antoshkin's user avatar
1 vote
2 answers
61 views

I use a static method from a common class in different activities. The method contains dialog. The dialog fires successfully from various activities. But when I declare the static dialog in the common ...
Zahidul's user avatar
  • 399
1 vote
0 answers
1k views

I've been trying to get the activity in a React Native app, but to no success. When I try getting it from public class MainActivity extends ReactActivity I get the following error when I try using the ...
Program-Me-Rev's user avatar
6 votes
1 answer
2k views

Run into strange behaviour when trying to add support for dark theme in existing app. I added values-night folder where I added new colors.xml with different hex for dark mode. Then I extended from ...
Marat's user avatar
  • 6,753
-1 votes
1 answer
334 views

I'm trying to get mainActivity context and mapView inside my fragment, I tried to write some code but when I write this: contextMain = activity?.baseContext!! mapView = view.findViewById<MapView>...
George Jung's user avatar
-1 votes
2 answers
425 views

I created a fragment in which through editText fields I would like to insert numbers to be used as parameters in a function created in another class (the function createPath of the NavFun class). The ...
George Jung's user avatar
0 votes
1 answer
623 views

I have a fragment Users which has 3 other fragments in it (tabs). For one tab ( called Friends2Fragment ) I made a recycler View and made an adapter for it. In each item of RecyclerView I have a ...
Daiana's user avatar
  • 19
2 votes
0 answers
1k views

I have a scenario where in I have to use WindowManager with application context, I don't Activity context there. But if I try to get WindowManager with application class, sometimes I get below ...
AndroidDev's user avatar
  • 1,635
0 votes
2 answers
4k views

I am trying to introduce preferences DataStore in my Android Compose app and several tutorials suggest the use of Conext for keeping the reference to the DataStore instance. E.g. https://...
TomR's user avatar
  • 3,364
0 votes
1 answer
1k views

I was always facing this memory leak warning without paying much attention to it, but now I'm looking into how to deal with it and, as I know I shouldn't use WeakReference and that sort of "...
Diego Perez's user avatar
  • 3,034
0 votes
0 answers
520 views

Here is my code fun Uri.getOriginalFileName(context: Context): String? { return context.contentResolver.query(this, null, null, null, null)?.use { val nameColumnIndex = it.getColumnIndex(...
Abx's user avatar
  • 11
1 vote
1 answer
960 views

I have an object with many screen related methods (I put only two as an example here) as follows: object AWScreen { private lateinit var context: Context fun init(context: Context) { ...
Diego Perez's user avatar
  • 3,034
67 votes
3 answers
41k views

Starting from API level 33 the getPackageInfo(String, int) method of PackageManager class is deprecated. Documentation suggests to use getPackageInfo(String, PackageInfoFlags) instead. But that ...
Marat's user avatar
  • 6,753
0 votes
1 answer
2k views

I am trying to get the package name of the app using the below code in my adapter java file. But I am getting nullpointer exception. Fatal Exception: java.lang.NullPointerException Attempt to invoke ...
sejn's user avatar
  • 2,834
1 vote
1 answer
616 views

I am developing android application which need auto restart when restart device for that I am using broadcast receiver with action BOOT_COMPLETED. Broadcast receiver is receiving message when I am ...
Nidhi Bhatt's user avatar
0 votes
1 answer
425 views

The following code crashes in 0.01% of app launches on a few devices [see below]. public class MyApp extends Application { private static MyApp app; public void onCreate() { super....
A.G.'s user avatar
  • 2,247
0 votes
0 answers
182 views

It has just recently come to my attention, that in many cases, such as when using a FutureBuilder or calling showDialog(), we have to define a builder which takes a BuildContext as an argument, and ...
Cedric's user avatar
  • 1,070
0 votes
0 answers
194 views

I'm using getContext() directly without using the requireContext(), but I got crash with Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:...
Alireza Tizfahmfard's user avatar
1 vote
1 answer
103 views

I'm a beginner to Android development. When making a singleton in the Application Context, here is my code. I pass the application context to the instantiation class Blah{ companion object { @...
joesph nguyen's user avatar
0 votes
1 answer
264 views

I'm trying to use the vibrator service inside a Thread class but when I do so, I have an error which says "Type mismatch: inferred type is String but Context was expected" here is my code : ...
GliderV5's user avatar
1 vote
1 answer
1k views

I have a global app settings class as follows: class AppSettings : MultiDexApplication() { override fun onCreate() { super.onCreate() instance = this resourses = ...
Diego Perez's user avatar
  • 3,034
0 votes
0 answers
1k views

I want to show a custom view when the app is turned off or when the app is turned on, depending on the phone state. so I use WindowManager. but get error message W/System.err: android.view....
hong developer's user avatar
0 votes
0 answers
848 views

Hello I have a button in recyclerview, I would like to show dialog when in one element of recyclerview the button is clicked. I have done: in Adapter: class SetGoalsAdapter( private val ...
chrisChris's user avatar
0 votes
1 answer
712 views

I am trying to use the architecture recommended by android in a project and I was wondering if it is legitimate and recommended to pass the context to the domain layer through the AndroidViewModel: ...
QenBau's user avatar
  • 425
0 votes
0 answers
303 views

I would like to provide context to FirebaseManager.kt class FirebaseManager @Inject constructor( @ApplicationContext val context: Context, firebaseFirestore: FirebaseFirestore, ...
chrisChris's user avatar
2 votes
0 answers
529 views

I am checking Sunflower sample app from Google. And I found an interesting part. override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, ...
c-an's user avatar
  • 4,210
0 votes
0 answers
1k views

I have a list of CustomClass and a function which returns this list in their own kotlin file. The function is only ever called from MainActivity but since it is not in the same file I cannot pass ...
Rory Nesbitt's user avatar
1 vote
0 answers
512 views

I have to get the context in the JNI_OnLoad. Due to some reason, I have to call the System.loadLibrary() in the attachBaseContext() but not onCreate(). I use the code in https://stackoverflow.com/a/...
Zhou Hongbo's user avatar
  • 1,555
1 vote
1 answer
265 views

First of all, I am completefy noob to android development and I am making this project for my college where I display items in a Recycler view, each Item has a delete button and it updates the product ...
OISHIK SENGUPTA's user avatar
0 votes
1 answer
177 views

I have an app that uses a popupWindow for user chat. It is launched from a Fragment, and the supplied context is getActivity(). I will be typing in the popupWindow's multilineEditText and, after about ...
Michael Plischke's user avatar
0 votes
1 answer
2k views

I want to display notifications that are being processed by a provider on an open gRPC stream. This is handled by notificationProvider.dart: if (notification.type == 0) { showOverlayNotification(...
Sara Petrovic's user avatar
0 votes
1 answer
1k views

I want to use this context to make a notification, but it should be called in a viewmodel that is made by hiltViewModel() function. How should I pass the context there?
ruskaof's user avatar
  • 307
0 votes
3 answers
371 views

I want to integrate ad to my app, but the problem is that the MobileAds.initialize(this){ initStatus-> not work this method( onCreateView) But I am use this method( onCreate: MobileAds.initialize(...
surendhar suren's user avatar
0 votes
1 answer
91 views

The following is from this post: public class MyApp extends android.app.Application { private static MyApp instance; public MyApp() { instance = this; } public static ...
drmrbrewer's user avatar
  • 13.4k

1
2 3 4 5
40