How to send data from class to activity on Android

All we need is a simple explanation of the problem, which is provided below. I have a problem with send data from class to activity. I have class (not activity) with static method: public static void printUsageStats(List<UsageStats> usageStatsList){ long totalTime = 0; for (UsageStats u : usageStatsList) { if ((u.getTotalTimeInForeground() > 0) && u.getPackageName().equals("com.facebook.katana")) { … Read more

Difference between switching from activity A->B->C- back to A via Intent vs several calls to finish()

All we need is a simple explanation of the problem, which is provided below. Say I have three activities A, B and C which are used in the following way. You start on activity A and press a button which takes you to B where you press another button that takes you to C. Now … Read more

How to open an activity from a fragment using imagebutton?

All we need is a simple explanation of the problem, which is provided below. I have a Navigation drawer that has four different fragments. On the Home Fragment Dashboard, I have eight different image buttons that I want to open a new activity I.E. when you click the Image Button TM’s I want it to … Read more

How to get the currently displaying fragment in Nav Controller

All we need is a simple explanation of the problem, which is provided below. I use a singe activity and embed multiple fragments into it. Now I would like to know within the single activity class, which Fragment is currently being displayed. How can I do this? I had a look at the solution from … Read more

Launching activity from the background, doesn't run the function in onResume()

All we need is a simple explanation of the problem, which is provided below. In my application, when the app stops recording audio it launches another activity and runs the function automaticSync() in the onResume(), but when the device is locked it does not run the function from the background, is there a way to … Read more

Android Date Picker showing unwanted view

All we need is a simple explanation of the problem, which is provided below. val datePickerDialog = DatePickerDialog( [email protected], R.style.DateTimePickerTheme, startDatePickerListener, myCalendar .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH) ) <style name="DateTimePickerTheme" parent="Theme.AppCompat.Light.Dialog"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/theme_blue</item> </style> above is my code , view showing as above image 1. but expected as below image 2. there is … Read more

jetpack Compose implement "Home button" functionality on backpress

All we need is a simple explanation of the problem, which is provided below. I have navigation via NavController. For some destinations i clear backstack like navController.navigate(nextScreen) { popUpTo(key) { inclusive = true } } and when system "back" button is pressed its returns on home screen. The tray is still holds the app, but … Read more

Jetpack Compose activities and composables for large projects

All we need is a simple explanation of the problem, which is provided below. I’ve noticed that several sources encourage developers to only use a single activity in their projects. When would it be appropriate to have more than 1 activity in a project? Is there a limit to the number of composables an activity … Read more

How to send from Fragment when clicking on ImageButton to Activity?

All we need is a simple explanation of the problem, which is provided below. It is necessary that in the Fragment, when you click on the ImageButton, the Activity opens.I’ve been reading all possible resources for two days and tried different methods, but none of them work. I am writing in Kotlin. Thanks in advance) … Read more