• Breaking News

    Tuesday, March 22, 2022

    Android Dev - Weekly Questions Thread - March 22, 2022

    Android Dev - Weekly Questions Thread - March 22, 2022


    Weekly Questions Thread - March 22, 2022

    Posted: 22 Mar 2022 07:00 AM PDT

    This thread is for simple questions that don't warrant their own thread (although we suggest checking the sidebar, the wiki, our Discord, or Stack Overflow before posting). Examples of questions:

    • How do I pass data between my Activities?
    • Does anyone have a link to the source for the AOSP messaging app?
    • Is it possible to programmatically change the color of the status bar without targeting API 21?

    Large code snippets don't read well on reddit and take up a lot of space, so please don't paste them in your comments. Consider linking Gists instead.

    Have a question about the subreddit or otherwise for /r/androiddev mods? We welcome your mod mail!

    Also, please don't link to Play Store pages or ask for feedback on this thread. Save those for the App Feedback threads we host on Saturdays.

    Looking for all the Questions threads? Want an easy way to locate this week's thread? Click this link!

    submitted by /u/AutoModerator
    [link] [comments]

    Weekly Who's Hiring Thread - March 21, 2022

    Posted: 21 Mar 2022 07:00 AM PDT

    Looking for Android developers? Heard about a cool job posting? Let people know!

    Here is a suggested posting template:

    Company: <Best Company Ever>
    Job: [<Title>](https://example.com/job)
    Location: <City, State, Country>
    Allows remote: <Yes/No>
    Visa: <Yes/No>

    Feel free to include any other information about the job.

    submitted by /u/AutoModerator
    [link] [comments]

    Thank you everyone. I got my first android job offer

    Posted: 22 Mar 2022 11:35 AM PDT

    Just been offered my first job as an android developer (and I've accepted) It will change my family's lives because the pay is double what I've been getting until now.

    I wanted to say thank you to everyone because I started learning Kotlin in October and I've benefited so much from the community here. All of the questions and answers I've found here. All the problems you have helped me solve. All the motivation when it's just really hard to learn. All of it has paid off and it's only up from here.

    P.s. if you are learning too, good luck you'll smash it anyday now!

    Take care everyone

    submitted by /u/ben306
    [link] [comments]

    Java 18 released

    Posted: 22 Mar 2022 08:07 AM PDT

    Just because Jetpack Compose is out, it does not mean we have to bury the old XML

    Posted: 22 Mar 2022 02:09 PM PDT

    I had the impression that Jetpack Compose is superior to XML in every aspect.

    It surely: - requires way less code - is better that code and design go to the same place - declarative like the web frameworks

    It kinda came as a surprise that the good old RecyclerView is not yet beaten. Compose does not have Grid layout and the animation (adding / removal) is not implemented. The performance from what I've seen did not match either with the old one.

    Which means I can make a much better app by implementing some components with the old system.

    Do you know of other areas where XML still does not beat Compose?

    submitted by /u/NotSoIncredibleA
    [link] [comments]

    Many libraries require an application context to be passed into an initializing method that is exposed for your application in the Application onCreate. What would happen if you pass in an activity context instead?

    Posted: 22 Mar 2022 05:41 AM PDT

    Emulator performance on integrated graphics

    Posted: 22 Mar 2022 11:59 AM PDT

    I am looking to buy a laptop which I would also use for some android development. Looking through the options within my budget(<1000€), I find a lot of laptops with only integrated GPU. Mostly looking at 5800U/H.

    Would that be fine for running an emulator or is it somewhat dependent on having a dedicated GPU?

    submitted by /u/_Moreplavec_
    [link] [comments]

    I programmed this so for the first time by myself so please please support me , download my Random Number Picker and add a comment and I will download yours too!

    Posted: 22 Mar 2022 03:32 PM PDT

    Android emulator suggestion(s) for commercial use?

    Posted: 22 Mar 2022 03:19 PM PDT

    I've been using Bluestacks previously for testing out apps in a virtual environment but as I understand, this is not allowed to be used commercially? I'm looking for an emulator that can be used commercially that is as straight-forward to use as Bluestacks (allowing multi-instances to run, and a very easy learning curve). Thanks in advance for any suggestions!

    submitted by /u/Guinea-Pug
    [link] [comments]

    SDK 31 update cause weird UI issues.

    Posted: 22 Mar 2022 12:27 AM PDT

    Hi everyone, i would like to apologise first if this was already asked,

    I recently update a project target sdk from 30 to 31, and discover some weird UI issues with constraints layout, where some items were out of positions or just effecting the UI layout when running the app.

    Using the latest material component does not fix this issue as well. Anyone facing a similar issue? Could not found this issue reported anywhere…

    Edit: No idea why sdk change is effecting the layout as well, if anyone could help shed some light (assuming if it does effect this). Thank you :)

    submitted by /u/Important-Lawyer-908
    [link] [comments]

    Returning Null When Logcat Shows Not Null

    Posted: 22 Mar 2022 12:18 PM PDT

    on logcat it say not null but

    java.lang.NullPointerException at "Auth.currentUser "

    fun linkFb() {

    Auth.addAuthStateListener {
    if(Auth == null)
    {
    Log.d("auth","null")

    }
    else {
    Log.d("auth","not null")

    }
    }
    val accessToken: AccessToken? = AccessToken.getCurrentAccessToken()
    val credential = FacebookAuthProvider.getCredential(accessToken?.token.toString())
    Auth.currentUser!!.linkWithCredential(credential)
    .addOnCompleteListener(this) { task ->
    if (task.isSuccessful) {
    Log.d("Linking", "linkWithCredential:success")
    val user = Auth.currentUser
    updateUI(user)
    } else {
    Log.w("Linking", "linkWithCredential:failure", task.exception)
    Toast.makeText(baseContext, "Authentication failed.", Toast.LENGTH_SHORT).show()
    //updateUI(null)
    }
    }
    }

    submitted by /u/Sensitive_Fold3014
    [link] [comments]

    Multi-Module-NextFlix-Composable

    Posted: 22 Mar 2022 12:07 PM PDT

    How can I make my custom data formats work in an Android app package?

    Posted: 22 Mar 2022 11:33 AM PDT

    I'm using some custom compression formats for some of the files in my .apk (for better download size) but want to make sure they play nice with the Google Play store, production installations, etc. . I know that such things are possible, at least for .dex files, because Facebook did it, but is it possible for other files as well? For example, if I compress a bunch of .pngs and .xml files with some custom format, and then on the first app open after installation I decompress them to be their expected formats of .png and .xml, will that cause problems? Can I decompress files into the installation folder (where they would've been had I not used this custom format), or do I need to put them somewhere else? Are there issues with code signing and MANIFEST.MF? Any concerns around any other file types?

    submitted by /u/michaeleisel
    [link] [comments]

    Why is changing the ringback tone (clientside) not supported by android? Could this be implemented in a new phone app, or would you have to change the operating system and perform a system update.

    Posted: 22 Mar 2022 10:58 AM PDT

    First, a definition: the ringback tone is what you hear, when you have started a call, but before the other party picks up. There is an annoying amount of articles using the term interchangeably with "ringtone".

    I really do not like my carrier (Verizon's) default ringback tones because they do not give you a precise idea of when a call starts exactly. If it starts anytime during the annoyingly long sections of silence, then I can end up waiting like 5 seconds longer before realizing I'm even connected. Not a huge deal, but it is still an annoyance I should easily be able to fix with software.

    There appears to be no interest in changing ringback other than https://stackoverflow.com/questions/15165752/can-i-manipulate-a-ringback-tone-on-the-fly, a completely stupid question with some unimaginative answers, notably

    I guess it's not a question related to any specific phone or phone-OS, it's a question of B's carrier. The tone you hear when you're waiting for an answer from your called party is not controlled by the phone of the called party, rather by their operator (the telephone company). The operator can give you some means to set a custom tone the caller will hear while trying to reach you and I could imagine that it would be theoretically possible for them to give away access to some API to change the tone in real time from an application on your phone, though I doubt that any operator does that at the moment.

    Considering I hate all the ringback tones anyway, I just want to override whatever crap the phone company is sending me and play a low constant tone or something clientside, until the call is actually connected - the absence of the tone indicates the call started.

    So, with all the introduction out of the way, is this possible if I fork the phone app or something, or is the behavior of the phone during a call a feature of the OS which would need deeper access to modify?

    submitted by /u/Magnus_Tesshu
    [link] [comments]

    [Code Review Request] Jetpack Compose Effect that runs only when App is Resumed (gist inside)

    Posted: 22 Mar 2022 10:39 AM PDT

    Hey guys,

    I had a requirement where I wanted to have an Effect that only runs when the app is in the foreground. Here's how I solved it:

    @Composable fun ResumedEffect(block: suspend () -> Unit) { var isResumed by rememberSaveable { mutableStateOf(false) } ResumeEffect { isResumed = true } PauseEffect { isResumed = false } if (isResumed) LaunchedEffect(Unit) { block() } } @Composable fun ResumeEffect(block: () -> Unit) { OnLifecycleEvent { _, event -> if (event == Lifecycle.Event.ON_RESUME) { block() } } } @Composable fun PauseEffect(block: () -> Unit) { OnLifecycleEvent { _, event -> if (event == Lifecycle.Event.ON_PAUSE) { block() } } } @Composable fun OnLifecycleEvent(onEvent: (owner: LifecycleOwner, event: Lifecycle.Event) -> Unit) { val eventHandler = rememberUpdatedState(onEvent) val lifecycleOwner = rememberUpdatedState(LocalLifecycleOwner.current) DisposableEffect(lifecycleOwner.value) { val lifecycle = lifecycleOwner.value.lifecycle val observer = LifecycleEventObserver { owner, event -> eventHandler.value(owner, event) } lifecycle.addObserver(observer) onDispose { lifecycle.removeObserver(observer) } } } 

    and this is how you can use it:

    ResumedEffect { while (true) { println("I am only running, when the app is resumed") delay(1000L) } } 

    What do you think? Since it's Android I'm never sure, if something is an anti-pattern, so feel free to correct/improve my code in the comments :)

    submitted by /u/VIOLETSTETPEDDAR
    [link] [comments]

    How long before Google punishes your ranking if your vitals are out of whack?

    Posted: 21 Mar 2022 05:53 PM PDT

    I have some vitals issues right now and I'm struggling to get back below the threshold. I've heard Google will lower your ranking on searches if that happens.

    Does anyone know (probably from experience) how long it might take before they do that to my app?

    submitted by /u/mntgoat
    [link] [comments]

    Google Play Console: "You need to use an SDK with a version number of 31 or lower"

    Posted: 22 Mar 2022 06:26 AM PDT

    I've had my compileSdkVersion and targetSdkVersion set to 31 for a while, and have been ignoring the Android Studio warning "Not targeting the latest versions of Android."

    Yet when I change the SdkVersions to 32 (and compile without incident; I've got both 32 and Tiramisu installed in Studio), uploading the resultant AABs to the Console results in the error, "You need to use an SDK with a version number of 31 or lower."

    Am I doing something wrong, or is the Console simply not allowing 32 yet?

    submitted by /u/NickMEspo
    [link] [comments]

    Use Koin in Hilt codebase

    Posted: 22 Mar 2022 05:27 AM PDT

    I am a newbie in Android development. I am trying to integrate a SDK in Multi Modular codebase. SDK is asking me to configure startKoin in custom Application class. But we are already using Hilt in our codebase. I am supposed to import SDK's koin modules and pass them to startKoin initialisation. This might be a basic usecase or I am thinking it all wrong 😅

    Could someone please help me out how am I supposed to integrate this SDK? TIA!

    submitted by /u/sreekar_s
    [link] [comments]

    English for developers

    Posted: 22 Mar 2022 05:11 AM PDT

    I just managed to get a new job position as Android developer in a big company.
    One of the interviews was in English (not my main language), and if they offered me a contract i think i can assume that my English level seemed adequate.
    But i feel like i need to improve a lot my writing and speaking skills to do my job properly in this new position.
    What should i do to improve in the 3 weeks left to start this new job?

    submitted by /u/Kimirron
    [link] [comments]

    i started a Foreground service now what is next?

    Posted: 22 Mar 2022 04:55 AM PDT

    Hello i recently learned how to start a foreground service and now im really lost of how I make it do tasks or where i right the code of the tasks it should do. And i got confused more when i searched online no really showed how to do it and all i got just keywords like intentservice/ thread /binding and i really don't know what to do

    submitted by /u/OutOf-void
    [link] [comments]

    How to Detect if account is already linked (Android Firebase)

    Posted: 21 Mar 2022 11:44 PM PDT

    My App Contains facebook and Google Authentication

    For Example if i login with google than Facebook it links facebook with google but next he log in with facebook it should not try to link with google again how can i detect if user account linked ?

    submitted by /u/Sensitive_Fold3014
    [link] [comments]

    With DB cache, do you need extra memory cache?

    Posted: 21 Mar 2022 07:20 PM PDT

    You can listen to Room DB data as a stream, so is there any need for an extra layer of memory cache?

    1. Phone flash storage is pretty fast, any visible advantage of memory cache?
    2. Android don't have traditional Desktop OS on demand paging due to wear on your flash drive with excessive read/write, so memory cache have advantage in this regard besides speed advantage.
    3. Dropbox Store Api support 2 layers of caching: memory and disk.
    4. When you say DB as single source of truth seems even more so you don't need extra memory cache.
    submitted by /u/ynkm1692
    [link] [comments]

    Fully customizable Jetpack Compose in the SDK by iDenfy

    Posted: 21 Mar 2022 10:56 PM PDT

    Hello, we at iDenfy have launched our Medium article about customizing Jetpack Compose and using it in the proprietary SDK.

    We're really excited about our approach and if you're SDK developer let me know your feedback!

    Cheers!

    submitted by /u/wellbranding
    [link] [comments]

    Unfurl, a library for generating link previews

    Posted: 20 Mar 2022 09:03 PM PDT

    The Material Design icon Backspace doesn't exist anymore?

    Posted: 21 Mar 2022 12:47 PM PDT

    Hey guys,

    I'm having a little issue (I know it seems pretty silly) adding a icon on a button on Android Studio actually only with a specific one.

    When I use the following code snippet I manage to add the the Material Design icon called ArrowBack normally:

    Button(onClick = { /*TODO*/ },modifier = Modifier.align(Alignment.End)) {Icon(imageVector = Icons.Filled.ArrowBack,contentDescription = null)}

    But when I try to add the one called Backspace that's like if one just doesn't exist it doesn't show up on IDE like suggestion opposite ArrowBack.

    Button(onClick = { /*TODO*/ },modifier = Modifier.align(Alignment.End)) {Icon(imageVector = Icons.Filled.Backspace,contentDescription = null)}

    Did that already ocurr with you guys?

    References:

    https://fonts.google.com/icons?icon.query=backspace

    submitted by /u/jluizsouzadev
    [link] [comments]

    Any advice for books on modern android testing techniques for both Java and Kotlin?

    Posted: 21 Mar 2022 06:37 AM PDT

    I'm having real trouble finding info about testing and what platforms and techniques I should be using.

    Currently, I've been working on an app using Cloud Firestore and doing mainly instrumented tests to check if the data layer is working correctly. These take forever and I know there has to a better way. There is so much info, much of it old, I just don't really know where to start.

    submitted by /u/BKMagicWut
    [link] [comments]

    What is the better Client Library to use in Websockets - Kotlin

    Posted: 21 Mar 2022 04:02 AM PDT

    I was looking for a better client library to use basically for websockets (Chat App)

    currently I have these options: -Okhttp -Ktor Client -Scarlet

    Appreciate your insights and answers? Thanks a lot!

    submitted by /u/rezerone
    [link] [comments]

    No comments:

    Post a Comment