A beginner's guide to Kotlin : androiddev
source link: https://www.reddit.com/r/androiddev/comments/7ac176/a_beginners_guide_to_kotlin/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Now that AS 3.0 is out I don't see any excuses for adopting Kotlin.
I think you mean "for not adopting Kotlin". 😃
The single line class definition, is that how you would really write it or would there be more newlines for readability?
It depends, most classes should be on several lines, but in Kotlin you often find yourself creating simple data classes with just a few properties which are perfectly fine on just one line. As soon as you get to 4+ properties or need anything in the class body you usually split them up.
I assume for a big object it would be on new lines, but that's up to each developer I suppose.
If your class needs more logic than simple getters and setters, then you'd have to flesh it out.
After using Kotlin for a week, I wish they reduce the number of colons needed, at least in method parameters (as sugar). I felt like I used so many keystrokes to simply declare methods compared to Java.
To add on to that, I find the use of fun
is a bit over the top. Personally, I feel that methods with object returns can remove the fun
declaration (as sugar, not actually removed from the language). Code becomes more concise and you can just skim methods without the fun keyword if you looking for methods that returns anything.
Those are just my personal opinions so far. Kotlin code can get a bit hard to read compared to Java though I guess maybe gets better with time. But I definitely love how you write less code though. That's a definite bonus.
What do you mean with colons? It's there as a delimiter for the type, and is not needed when the type can be inferred. As for skipping the 'fun' keywors, I'm not sure how the syntax would look like then - lika Java's? Either case, it would ruin the consistency and make it confusing.
This is a single fucking blogpost. This isn't a guide. Stop fucking plastering your clickbegging garbage all over Reddit, /u/fractalwrench.
Awesome to see companies like Bugsnag bringing Kotlin to the forefront!
Sounds interesting, never tried Kotlin. Looks a bit like Swift.
I believe Kotlin was developed first, so Swift looks like Kotlin. =)
Somewhat comprehensive (covers interesting—for a beginner—topics) and nicely written article. Thanks for writing and publishing it!
should I abandon java if i have to do android app development ? (no games).
Decide for yourself. You have plenty of 5-minute overviews of Kotlin to make it an easy choice.
Wow, creating model classes looks so much simpler. Creating get and set for each property in Java was hella tedious. C# also has a nice way: string name {get; set;}
How much do apps sell for? Let's say I have an app that has 50 k daily active users but is free and does not generate any revenue. Would it sell? What if it has 10 k daily active users but it made some revenue? Or any links where I could learn about this would be helpful! Thanks.
When I release an application, I also release a relative website: IOS and Android version, legal documents, contact, etc.
Most of the time, a straightforward site is enough but it takes time to develop.
So I wondered: why not use the data from the app store page of the app to generate a site with everything I need?
I'm building a service to do that and am curious to know if this is something you actually need and would purchase a subscription for?
Demo with the app WelcomeNo idea why it seems so trendy compared to Gradle Groovy: it's slower, less stable, more verbose, harder to read and write, more limited, and most examples are still in Groovy and I'm already bored of wasting literally hours trying to translate them to Kotlin.
I had successfully avoided it until earlier this week when I wanted to try to build a Kotlin Multiplatform Mobile app and couldn't find any example using Gradle Groovy.
I need to collect some simple data about native crashes (C/C++/...) hapenning in my app - the fact that a crash has happened and the name of the binary it has happened in.
I know this can easily be achieved by connecting Crashlytics and looking at the data in the Firebase console, but I can't do that since I need to do some (simple) extra handling of the crash from within the app.
I've tried to find a way to observe the Crashlytics crashes-handling in the code (to subscribe to the Crashlytics class somehow), but it seems there's no way to do that.
I also know I can create a small C-lib which would receive crashing signals by <signal.h>, but it seems like a too complex way to achieve something that probably has a simpler solution.
Is there a simpler solution though?
Maybe there's a library which allows to do just that - to observe native crashes from within Java/Kotlin?
Dialogs is an Android library to ease the initialization of dialogs in android apps through Jetpack Compose.
Features
Written in Kotlin
No boilerplate code
Easy initialization
Written for Jetpack Compose
I have added a cool sample app that helps better understand the usage.
GitHub - https://github.com/akshaaatt/Dialogs-Android
Make sure to star the project if you appreciate the work :)
Hope this helps you out!
DialogsI dunno where to ask about this
But my recent update got rejected because apparently we "do not comply to User Policy"
APK REQUIRES PROMINENT DISCLOSURE
Your app is uploading users' Contact list information without a prominent disclosure. Prior to the collection and transmission, it must prominently highlight how the user data will be used, describe the type of data being collected and have the user provide affirmative consent for such use.
For further details on the valid prominent disclosure requirement, please review the “Prominent Disclosure & Consent Requirement” section under the User Data policy.
the problem is that feature already like that since first release, and we only use READ_CONTACTS permission to retrieve the phone and name from user selected contact data.
I've googled a lot about how to get contact data and looks like my implementation already correct, using ACTION_PICKS
fun selectContact() {
val intent = Intent(Intent.ACTION_PICK).apply {
type = ContactsContract.Contacts.CONTENT_TYPE
}
try {
activity.startActivityForResult(intent, REQUEST_SELECT_CONTACT)
} catch (e: ActivityNotFoundException) {
Toast.makeText(activity, "Aplikasi Contact tidak ditemukan", Toast.LENGTH_SHORT).show()
}
}
yet when I tried to retrieve the data without READ_CONTACTS permission I got empty cursor data
So I kinda lost of what to do here..
FYI my app is some kind of food delivery service and we request contact in case user want to pick number from their contact as recipient
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK