• Breaking News

    Sunday, August 22, 2021

    Android Dev - Weekly Questions Thread - August 17, 2021

    Android Dev - Weekly Questions Thread - August 17, 2021


    Weekly Questions Thread - August 17, 2021

    Posted: 17 Aug 2021 06: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]

    I would like to share my Kotlin Coroutines playground

    Posted: 22 Aug 2021 02:29 AM PDT

    Hello everybody! Occasionally, our Android team has Tech Fridays, during which we present some new things we did recently try or worked on. Usually I am presenting things related to coroutines and my sample repository already have grown with useful examples.

    I would like to share my Coroutine Recipe repository with you guys too. Maybe you will find it useful as it covers everything starting from the basics up to some more advanced stuff. I have also implemented some side-by-side comparisons with RxJava, Channels vs Flows, LiveData vs StateFlow etc.

    It's nothing superb sophisticated, but I did choose maybe most useful use cases which we also use in our company. You can find the repo here:

    https://github.com/edgar-zigis/CoroutineRecipes

    Project can be run out of the box on IntelliJ.

    Cheers!

    submitted by /u/biomatic-1992
    [link] [comments]

    Show off your Play Store™ app's downloads and rating in your repo

    Posted: 22 Aug 2021 12:48 AM PDT

    A small movie project using Jetpack Compose, Hilt based on modern Android tech stacks.

    Posted: 22 Aug 2021 07:33 AM PDT

    Where's a good place to learn testing?

    Posted: 22 Aug 2021 02:22 AM PDT

    I'm aware of the main Google tutorials and the codelabs and several third party tutorials, paid and free.

    But they seem inadequate and aren't consistent across different sources. Some also suggest avoiding Roboletric and avoiding UI tests on the View layer but there hasn't been enough examples of how to do it right.

    Androidx also seems to have messed up some tests and sometimes it's crashing because of dependency versions, but I don't really know why.

    I have code that works when in a sample application, but copied to a production app, it gives obscure crashes even with the exact same imports and dependencies. And it seems like I don't understand it enough to fix it myself.

    Are there any tutorials that you guys recommend? Specifically I'm trying to just test whether my camera & file system code creates appropriate files on any version of Android and crashes appropriately when not allowed permissions.

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

    Upgrading Android Studio often breaks my project in unpredictable ways, so I created a script to clear everything and start from scratch

    Posted: 21 Aug 2021 11:49 AM PDT

    https://github.com/chimbori/reset-android-studio

    I'm tired of wasting multiple hours each time I upgrade Android Studio and notice that a project that used to build correctly no longer builds at all.

    Each time, I've tried clearing a different location on my disk, and over time, I've collected into a shell script all the different things that need to be handled.

    If you have a similar need, please feel free to use it. It's open source and licensed as Apache 2, so do what you want with it.

    If you have discovered additional places that also need to be cleared, feel free to send pull requests or leave a comment here.

    Hoping this saves all of us collectively a huge amount of time and headaches!

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

    Most user-friendly APK Distribution, outside of Play Store

    Posted: 21 Aug 2021 08:55 PM PDT

    Hey All,

    I'm looking to distribute an enterprise Android app, but cannot find a distribution method that is workable and provides a good user experience.

    The app doesn't provide any value for the public, so I'm told that it wouldn't be approved on the Public Play Store.

    The app has been approved for Private Distribution, but users aren't part of an organisation and aren't using company owned devices.

    Apple handles this use case by generating links which allow a private app to be downloaded through the App Store, without needing the users to belong to an organisation (an organisation only needs to exist to generate the links).

    Just wanting to confirm there's no equivalent distribution method for Android apps, and if that is the case - what is the most user-friendly way to distribute the app? The best (and only) method I've found so far is hosting the APK on a website for users to download, however, users are prompted with several steps prior to being able to 'install' the app.

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

    An open-source project to put my skills to use

    Posted: 22 Aug 2021 08:06 AM PDT

    I have recently learned android app development using java and i would love to use my skills to contribute to opensource....can you guys suggest me some projects? Thank you.

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

    Why twice if both need to be same?

    Posted: 21 Aug 2021 09:10 PM PDT

    Why twice if both need to be same?

    Trying to sign apk in android studio. While creating key, it says,

    Different store and key passwords not supported for PKCS12 KeyStore.

    If so, then why I need to input it twice?

    https://preview.redd.it/ec3ftlr43ui71.png?width=899&format=png&auto=webp&s=f0101a8587935c4f2868d39b9b79c7a2334eec34

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

    Google Billing requirement for a semi-physical product?

    Posted: 22 Aug 2021 05:25 AM PDT

    Trying to figure out whether we have to use google billing and pay the commission (as well as on the Apple side) for my app.

    It's basically a subscription service for codes at our partner restaurants i.e. people sign up for x/mo, they then go to a restaurant of their choice and show the code and get their discount. So it is somewhat physical, but it's a bit of a fuzzy line.

    Our app is currently built using Cordova (for the purposes of being lean) with most of the app just being the mobile website, including the subscription part which uses Stripe.

    What do people think? Are we okay to not use google billing?

    If we aren't eligible to skip google billing, guessing we're not allowed to redirect people to sign up on the website?

    For reference, here's the policy link: https://support.google.com/googleplay/android-developer/answer/10281818

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

    WakeLock not turning on the screen

    Posted: 22 Aug 2021 05:07 AM PDT

    I am trying to create a basic alarm clock app. I set the alarm using the setExact method of the AlarmManager. And then I created a BroadcastReceiver that will display a toast and will start a new activity when the previously set alarm goes off. I also have a WakeLock in my BroadcastReceiver to try to turn on the screen. The BroadcastReceiver is working. It is able to receive the event and then created the activity. But the screen is not turning on. I've read and followed a lot of answers of posts like this in SO but I still cant make it work.

    This is my code for setting the alarm:

    alarmIntent = Intent(context, AlarmReceiver::class.java).let { intent -> PendingIntent.getBroadcast(context, 1, intent, 0) } val alarmTime = Calendar.getInstance().apply { timeInMillis = System.currentTimeMillis() set(Calendar.HOUR_OF_DAY, alarmForm.time.get(Calendar.HOUR_OF_DAY)) set(Calendar.MINUTE, alarmForm.time.get(Calendar.MINUTE)) set(Calendar.SECOND, 0) } alarmManager.setExact( AlarmManager.RTC_WAKEUP, alarmTime.timeInMillis, alarmIntent ) 

    This is my BroadcastReceiver:

    class AlarmReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val wakeLock: PowerManager.WakeLock = (context.getSystemService(Context.POWER_SERVICE) as PowerManager).run { newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyApp::MyWakelockTag").apply { acquire(10*60*1000L /*10 minutes*/) } } Toast.makeText(context, "Wake Up!", Toast.LENGTH_LONG).show() val alarmDisplayIntent = Intent(context, AlarmDisplayActivity::class.java) alarmDisplayIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK context.startActivity(alarmDisplayIntent) wakeLock.release() } } 

    And this is the activity I display when alarm goes off:

    class AlarmDisplayActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_alarm_display) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } } 

    I am using a phone with android version 9. My minSdkVersion is 21. What do you think I am doing wrong or am I missing something?

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

    Emulating a USB Device - Is This Possible?

    Posted: 22 Aug 2021 03:03 AM PDT

    I wanted to see if it were possible to emulate a USB device as being plugged into an Android device. Perhaps using some ADB command and push a file to the device over USB?

    My goal is to emulate a device using a specific VID/HID.

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

    Any declarative based libraries

    Posted: 21 Aug 2021 03:24 PM PDT

    Hi, just wondering if there are any good declarative libraries that you guys know of.

    As an Android and React dev I've seen a bunch of React tools that would be great to utilise in Android.

    For things like

    • Network caching, fetching, pagination e.g. React-query https://react-query.tanstack.com/.
    • Forms with validations e.g. like React Formik alongside Yup validation. https://formik.org/
    • Theming. Something that helps build up custom design systems. Not that important since it's pretty straightforward to do manually but annoying with how you need to set up your own composition over material design. Styled-System of sorts which I have duplicated so far with providing my own composition with semantics values for spacing, radius, colours, line heights etc...

    Any with multiplatform support would be a plus. In case KMM would ever do compose for iOS.

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

    Is it wise to download pre-built flutter template app, with a design that's already made, and left for to do is just the back end part?

    Posted: 21 Aug 2021 05:50 PM PDT

    Google Play Console analytics vs. 3rd party solutions

    Posted: 21 Aug 2021 01:03 PM PDT

    Hi guys,

    what do you think of Google Play "native" app analytics: is it decent (reliable and timely) and worth to work with, or is it better (if budget allows) to integrate 3rd party solutions (e.g. Localytics, Kissmetrics, Mixpanel, etc.) and use them instead?

    What are the major points of your personal concern with analytics from Google? Which alternatives are way better and you surely recommend them?

    Thank you!

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

    Is Java of Kotlin better for wear OS/Androi app development?

    Posted: 21 Aug 2021 07:19 PM PDT

    I've mostly programmed in python, and I knew how to use Java and some kotlin about a year or 2 ago. I'd like to get back developing and make my own apps for personal use. Is it better to use Java or kotlin. I know Java was the OG but now Kotilin has the official title. Soooo thoughts?

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

    No comments:

    Post a Comment