sarmad sohaib
10/20/2022, 8:49 PMBroadcastReciever()
somewhere else, which can be viewModel
, repository
, or fragment
. I am not sure where to send data from receiver because i am newbie to MVVM architecture. I have three questions:
1. Where to send data from receiver
? ViewModel
or repository
?
2. How to send data by not breaking the best practices and MVVM.
3. Should i use Coroutines
in receiver? If yes, how?
I am a beginner so please tell me if question is unclear. Code examples will help me a lot. I have tried almost everything from Internet and not a single solution was easy to understand.
Thank you!zt
10/21/2022, 4:50 AMPer Jansson
10/21/2022, 7:41 AMmodifier = Modifier.testTag("HomeButton")
Test
// I've tried different ways of finding objects and different ways of waiting, but nothing seems to make the tests less flaky
@Test
fun verifyAllPages() {
device.wait(Until.findObject(By.res("HomeButton")), DEFAULT_WAIT_TIME).click()
device.wait(Until.findObject(By.res("MenuButton")), DEFAULT_WAIT_TIME).click()
device.wait(Until.findObject(By.res("MenuItem_1")), DEFAULT_WAIT_TIME).click()
...
...
...
}
Questions that I have
1. Is this really how flaky UI Automator test are expected to be, or am I missing something?
2. What alternatives do I have if I want to write a test that visits all, or at least some, of the screens in the app?
3. How are people in general testing the Android apps? Coming from the web world it is common to build high level, “opaque box” tests using e.g. Cypress or Playwright.KamilH
10/21/2022, 8:33 AMIdlingResources
in app architecture that uses `Flow`s a lot? In my app I tried to implement similar solution to this however it doesn’t work well, because here we are waiting until job is not active anymore and it’s problematic when we, for example, observe changes in the database, because this kind of streams are not completing at all, which means we inform Espresso that app is busy all the time and tests are not resuming.
Maybe it would be better to inform Espresso that the app is busy only when Flow
is “processing” some value, however that doesn’t seem to be possibleSlackbot
10/22/2022, 10:47 AMMilo
10/22/2022, 8:59 PMMilo
10/22/2022, 9:22 PMalarmManager.setExactAndAllowWhileIdle(
AlarmManager.RTC_WAKEUP,
time,
pendingIntent
)
Milo
10/22/2022, 9:22 PMval time = getTime()
Milo
10/22/2022, 9:22 PMprivate fun getTime(): Long {
val minute = binding.timePicker.minute
val hour = binding.timePicker.hour
val day = binding.datePicker.dayOfMonth
val month = binding.datePicker.month
val year = binding.datePicker.year
val calendar = Calendar.getInstance()
calendar.set(year, month, day, hour, minute)
return calendar.timeInMillis
}
Milo
10/22/2022, 9:22 PMSam Stone
10/24/2022, 6:07 AMcedric akrou
10/24/2022, 9:15 AMcedric akrou
10/24/2022, 9:15 AMhttps://www.youtube.com/watch?v=Awi4J5-tbW4&ab_channel=AndroidDevelopers▾
diego-gomez-olvera
10/24/2022, 9:36 AMGestureDetector.OnGestureListener
also seen in StackOverflow: Util API 32 the method could return null
but since API 33 it's marked as @NonNull
. There are possible workarounds for this:
• A Java wrapper which doesn't enforces the nullability to keep it @Nullable
• Remove override
and suppress the warning
None of them seems ideal, what do you use in your projects? I remember an Android blog post about the topic of migration but when previous versions could pass null
are more problematicTino
10/24/2022, 5:46 PMMoritz
10/24/2022, 7:38 PMPoyyamozhi Ramakrishnan
10/25/2022, 2:43 PMcedric akrou
10/25/2022, 2:55 PMhttps://youtu.be/CIZU_NNAZsA▾
Sky
10/25/2022, 8:29 PMAshish Gautam
10/27/2022, 12:10 PMMilo
10/27/2022, 8:42 PMSlackbot
10/27/2022, 10:00 PMzt
10/28/2022, 4:33 AMTower Guidev2
10/28/2022, 8:18 AMAshu
10/28/2022, 8:29 AMLee Delarm
10/28/2022, 6:41 PMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
val scope = rememberCoroutineScope()
var text by remember { mutableStateOf("Loading") }
LaunchedEffect(true) {
scope.launch {
text = try {
Greeting().greeting()
} catch (e: Exception) {
e.localizedMessage ?: "error"
}
}
}
Greeting(text)
}
}
}
}
}
Lee Delarm
10/28/2022, 6:42 PMGreeting().greeting()
should be returning a string of dataRacka N
10/29/2022, 10:55 AM:benchmark
module to run tests. Clicking on the test class opens a dialog to choose a module but none of my modules are being listed. If I change the build variant of my main :app
module to debug
I can see all my other module except the one for :benchmark
. See the comments for my gradle setup. I'm on Android Studio Electric Eel Beta 03Michael Job
10/30/2022, 1:58 PMfun getTimer(): String {
val timeElapsed = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.of("Europe/Paris"))
val formatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS").withZone(ZoneId.of("Europe/Paris"))
return timeElapsed.format(formatter) //returns 01:00:00.000 //why 1 hour ???
}
Asad Mukhtar
10/30/2022, 7:17 PMfun Activity.setSystemPaddingForAppContent(view: View) {
WindowCompat.setDecorFitsSystemWindows(window, false)
ViewCompat.setOnApplyWindowInsetsListener(view) { view, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures())
// Apply the insets as padding to the view. Here we're setting all of the
// dimensions, but apply as appropriate to your layout. You could also
// update the views margin if more appropriate.
view.updatePadding(insets.left, 0, insets.right, insets.bottom)
// Return CONSUMED if we don't want the window insets to keep being passed
// down to descendant views.
WindowInsetsCompat.CONSUMED
}
}
But the problem is that I have a simple activity due to the above function ScrollView, NestedScrollView not scroll even the content is scrollable.Asad Mukhtar
10/30/2022, 7:17 PMfun Activity.setSystemPaddingForAppContent(view: View) {
WindowCompat.setDecorFitsSystemWindows(window, false)
ViewCompat.setOnApplyWindowInsetsListener(view) { view, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures())
// Apply the insets as padding to the view. Here we're setting all of the
// dimensions, but apply as appropriate to your layout. You could also
// update the views margin if more appropriate.
view.updatePadding(insets.left, 0, insets.right, insets.bottom)
// Return CONSUMED if we don't want the window insets to keep being passed
// down to descendant views.
WindowInsetsCompat.CONSUMED
}
}
But the problem is that I have a simple activity due to the above function ScrollView, NestedScrollView not scroll even the content is scrollable.