• Breaking News

    Wednesday, November 20, 2019

    Android Dev - #AskAndroid at Android Dev Summit 2019: Architecture Components -- worth noting that Yigit Boyar says at 6:40 "SingleLiveEvent - don't use it"

    Android Dev - #AskAndroid at Android Dev Summit 2019: Architecture Components -- worth noting that Yigit Boyar says at 6:40 "SingleLiveEvent - don't use it"


    #AskAndroid at Android Dev Summit 2019: Architecture Components -- worth noting that Yigit Boyar says at 6:40 "SingleLiveEvent - don't use it"

    Posted: 20 Nov 2019 04:58 AM PST

    I'm getting into android development coming from a Unity C# game dev background. Should I focus more on java or kotlin or both? what about flutter? Seems confusing.

    Posted: 20 Nov 2019 05:10 AM PST

    List item ViewModel holds reference to parent ViewModel

    Posted: 20 Nov 2019 04:42 AM PST

    Hi everybody, I've got a design-related question.

    In my screen I have a list, and since each item is a bit complex, each item has its own ViewModel.

    In addition to that, the activity itself has its own ViewModel as well (let's put aside all the Navigation/Single-Activity-Multiple-Fragments design for a second).

    In some cases (specifically during clicks) I need to propagate events/method calls from the list-items' VM to the "parent VM".

    Initially I did this by having each of the list items hold a RxJava's PublishSubject, have that subject publish an event (a payload of sorts), and via the list's adapter, subscribe to all the VMs and pass that event to the activity or the "parent VM".

    Since that created a whole lot of boilerplate code and greatly reduced readability, I've decided to have each of the list-item's VMs hold a direct reference to the "parent VM" and on each event simply call the parent VM's relevant method.

    So far, there have been no functional problems, no memory leaks or anything of the sorts (I'm not holding a reference to the activity, fragment, or any view whatsoever).

    Since all this stays in the ViewModel's "level" of the architecture, I think this design is valid, but I'd like to get a second opinion. I haven't been able to find any official material on the subject, so I thought I'll try my luck here, how do you handle this case in your projects?

    TL;DR - how do you pass events/method calls/connect ViewModels of list items to the ViewModel of the fragment/activity/ parent view?

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

    Android Studio vs IntelliJ Ultimate Version

    Posted: 20 Nov 2019 04:32 AM PST

    Hey everybody,

    since my beginning with Android programming I use Android Studio. As the Ultimate Version of IntelliJ is free for students I applied and got it. Now Im asking myself if it's better to use IntelliJ than Android Studio. For example the Ultimate version has its own built in window for databases.

    So I wanna ask you, what you are using and why.

    Thanks for your answers

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

    Unifying Background Task Scheduling on Android

    Posted: 19 Nov 2019 11:16 AM PST

    VMWare: Adopting a Cross Platform Strategy for Mobile Apps

    Posted: 19 Nov 2019 10:43 AM PST

    Kotlin Android All Social Firebase Authentication With Coroutine, Koin, MVVM

    Posted: 20 Nov 2019 05:33 AM PST

    [Question] How to get Gradle to copy a file from one folder to another before building?

    Posted: 20 Nov 2019 07:06 AM PST

    How do I get Gradle to copy files from one folder into the another folder every time we build (debug, release, everything)?

    I'm just trying placeholder files for now, but ultimately this is because I have files that are shared between builds for different platforms (Android, iOS, PC) that need to be copied in before the build.

    I've tried adding a task [placeholder, internal file path, just for a simpler test] like:

    task copyFiles(type: Copy){ from file("src") include '**/*.txt' into file("src/movetest") println 'Just attempted file copy' } 

    and running it with this method but it just complains

    Could not get unknown property 'Compile' for project ':app' of type org.gradle.api.Project. 

    and if I try putting

    build.dependsOn copyFiles; 

    then it will print any println that I have in the task, but not actually copy the files. I've tried formatting the paths in 10+ ways and nothing works.

    Thanks for any help.

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

    [Question] What are my obligations when I use an Apache 2.0/MIT/BSD-2 licensed library in my app?

    Posted: 19 Nov 2019 10:05 PM PST

    Hi /r/androiddev

    As the title says, I'm confused (and trying to avoid any future lawsuits) when I'm using an Apache 2.0 licensed library in my app.

    For example, if I use OkHttp (Apache 2.0) and Retrofit (Apache 2.0) in my app, what are my obligations as an app developer?

    As far as I can see, I should "include" these licenses in my app.

    I'm trying to understand what does "include" mean in this case.

    Do I need to just copypaste the license agreement text into my app code?

    Or do I need to explicitly mention the list of the open-source libraries in a section of my app (like Whatsapp, Netflix, Youtube, etc.)

    Any links to any reliable literature would be much appreciated.

    Thanks in advance!!

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

    Kotlin for the Glaxy Watch Active?

    Posted: 20 Nov 2019 05:28 AM PST

    I am wondering if it's possible to use kotlin when developing an application for the Samsung Galaxy Watch Active (2)?

    After searching the web, I cannot find any documentation about this.

    If not kotlin, what do you recommend?

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

    Portfolio ideas

    Posted: 19 Nov 2019 05:42 PM PST

    Hello everyone,

    I'm trying to get my first job as an android developer (change of careers) but I'm guessing my portfolio is lacking since I haven't been able to even get an interview. Sure the apps in it are "simplistic", but these are just some ideas I gathered from the web. Since I made these apps (solely for the purpose of showing some work), I moved to Kotlin, learned MVVM, data binding, and a couple of jetpack libraries (room, and navigation mainly).

    So I was thinking of going back and rework these apps, but figured I'd ask first if they're even good enough to have in a "portfolio" to get a job. If not could anyone more experienced recommend any projects to have? I'm working on a personal project to publish on the playstore now but it's too big to rush, and might take a while. Also, should I make a website and have screenshots and stuff or is that not necessary?

    Link to GitHub if anyone has the time and feeling generous enough to take a look: https://github.com/yebaital

    Thanks in advance!

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

    Problems with XML activity in Android studio

    Posted: 20 Nov 2019 01:10 AM PST

    I am currently building an Android app which is basically a messaging app. I am trying to make a new activity where basically, the user selects who to message from a list of people. It is going to be an image view to the left with a text view ok the right for a profile pic and username respectively. However, when I create a new layout resource file, both the image view and the text view I create are bounded to the left, and I cannot move them, only resize them. How do I go about fixing this? Thank you.

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

    Is there any way to simply operate with files on my PC from Android?

    Posted: 19 Nov 2019 11:17 PM PST

    For example, i have a huge library of images and now i want to sort it manually. Doing this with keyboard and mouse is good enough but it is more or less boring so i wrote some Telegram bot to do this on my phone.

    Problem with it consist in hardcoded paths to folders, and general latency (PC->telegram servers->phone->telegram servers->PC), so i want to write app to do so. I have some experience in android programming, but i cannot think about way to provide photos to my phone either of copying it on device and after sorting copying it back on computer.

    Is there anything to work with files directly without bringing servers from the other sides to do so?

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

    Status bar is flickering

    Posted: 19 Nov 2019 09:23 PM PST

    My activity status bar is flickering when I make show full screen and hide full screen with the following code. How to remove the flickering effect.

    fun showFullScreen(activity: BaseActivity) {
    activity.window?.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN)

    }
    fun hideFullScreen(activity: BaseActivity) {
    activity.window?.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)

    }

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

    [GLES] [jni] how to set the offset to GL_PIXEL_UNPACK_BUFFER for glTexImage()

    Posted: 19 Nov 2019 07:10 PM PST

    I want to using the PBO method to update a texture to save more CPU times. I heard that if I have bind a buffer to the GL_PIXEL_UNPACK_BUFFER after activated a texture, I can use the data parameter in glTexImage() as the offset to it.

    But in Java, that parameter is a ByteBuffer type variable, how can I store an offset in it?

    I tried

    ByteBuffer foo_offset = ByteBuffer.allocateDirect(4); foo_offset.order(ByteOrder.nativeOrder()); foo_offset.asIntBuffer().put (0);

    GLES.glTexImage2D(GLES20.GL_TEXTURE2D, ... , foo_offset);

    foo_offset won't be parsed as zero and what I should do if I want to store an valid offset in it?

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

    TIL: Modifying a collection while iterating over it without an iterator will cause `ConcurrentModficationException`

    Posted: 19 Nov 2019 10:56 PM PST

    How to Unit Test Android Activity/ViewModel/Repository

    Posted: 19 Nov 2019 04:04 PM PST

    Hi Everyone,

    I am new to unit testing in android. I have this simple piece of code, can someone tell me if this code is testable and if so, how I can start writing test for it. Its a simple viewmodel/activity relationship. Feel free to point out any styling or design improvement I can make. Example is greatly appreciated

    <------------Code Sample ----------------->

    ViewModel:

    Note: newWorkRepository is injected

    val carPriceLiveData: MutableLiveData<ViewState<List<CarModel>>> = MutableLiveData() fun getCarPrice(): LiveData<ViewState<List<CarPriceModel>>> = carsPriceLiveData fun getPrice(location: LocationModel) { networkRepository.getPrice(location.type, location.zipCode,location.latitude,location.longitude) { cars -> carsPriceLiveData.value = ViewState.success(cars) } } 

    Activity:

    Note: ViewModel is injected from a ViewModelFactory

    override fun onCreate(savedInstanceState: Bundle?) { viewModel.getCarsPrice().observe(this, listCarUpdateObserver) val locationType = LocationModel(type = ActiveLocation.NONE) viewModel.getPrice(locationType) } private var listCarUpdateObserver = Observer<ViewState<List<CarPriceModel>>> { state -> when (state.status) { Status.SUCCESS -> { priceListAdapter.submitList(state.data) } Status.ERROR -> { /*TODO show error with location*/}else -> {/*TODO do something*/ } } } 

    NetworkRespitory:

    note: priceApp is injected

    fun getPrice(locationType: ActiveLocation?, zipCode: StringcarItems: (List<CarPriceModel>?) -> Unit) { var callback = when (locationType) { ActiveLocation.ZIPCODE -> { zipCode?.let {priceApi.getPriceWithZipCode(zipCode)} } else -> {priceApi.getPrice()}} callback?.enqueue(object : Callback<PriceResponse?> { override fun onResponse(call: Call<PriceResponse?>,response: Response<PriceResponse?>) { if (response.isSuccessful) { var carsList = emptyList<CarPriceModel>() val responseBody = response.body() carList = if (responseBody != null) getCarsList(responseBody) carItems(carsList) } } override fun onFailure(call: Call<PriceResponse?>,t: Throwable) {/*TODO: ERROR MANAGEMENT*/}}) } 
    submitted by /u/truelai108
    [link] [comments]

    Why You Should Build Your Android App in Kotlin?

    Posted: 20 Nov 2019 12:21 AM PST

    Why You Should Build Your Android App in Kotlin?

    https://preview.redd.it/xwlm7ghjwsz31.jpg?width=1350&format=pjpg&auto=webp&s=42a6dd69735927b5f8eb3c967a87491b075ed6bb

    Android App in Kotlin

    If you have already come to the point to develop an Android app, then Kotlin is the right choice for you. Below we'll together investigate the features of this app development language that is widely accepted by various influential companies.

    1. Fast

    Kotlin is clear and brief. Android development with Kotlin helps increase the efficiency of developers thanks to its succinct and instinctive syntax. As a result, more work is done in less time, and fewer lines are required to be written to complete the working code.

    The Kotlin Android app projects can be set up to function within a short time. Yet, the most essential part is that this language can easily debug without any difficulty.

    2. Adaptable

    While dealing with a Kotlin app, the major emphasis is placed on making sure that the existing codebase can be used for any kind of development, either be it server-, client-side, web or Android.

    3. Modern

    In terms of the avant-garde, a great fit for developing native applications is Kotlin for Android developers. This brings new advantages of a modern development language to the Android platform, yet, no new restrictions are introduced. And the fantastic thing is that Google announced the language official for Android development and it reached official support.

    4. Safe

    Kotlin has a new improved type system that brings better type safety and fixing. Although Java has been around for years, if we compare it with Kotlin from the perspective of the Android App Development, definitely, Kotlin has an advantage over Java.

    Kotlin focuses on null safety. One of the main objectives of the system is to eliminate the danger of null reference (NullPointerException) from the code. Generally, Kotlin introduces two types of references that are interpreted to give the developer information about the accuracy of a program along with the time. These references are either nullable or not. As a rule, Kotlin accepts that the value can never be null. If null is assigned to the reference "a", it causes an error.

    Kotlin system also introduces a syntax for safe calls. It gives the developers an opportunity to execute any action only in the case when the particular reference holds a not nullable value.

    For Android app development, Kotlin offers better benefits than Java. This app development language requires lesser code so that there is a less chance that code to fail. On the other hand, the code written in Kotlin is easier to understand. As a result, reading the codebase, different developers do not require much effort to understand the already written codes. All in all, it offers more code implemented in less time, yet less time is spent on fixing errors.

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

    How to set some fragments fullscreen in Navigation Component

    Posted: 19 Nov 2019 01:20 PM PST

    I have used navigation component for one large scale project. Single activity and all screens are based on fragments. How to set some fragments fullscreen e.g splash screen, without affecting others? I would like to achieve the effect of WindowManager.LayoutParams.FLAG_FULLSCREEN, however in fragment.

    Any help greatly appreciated!

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

    No comments:

    Post a Comment