Questions Thread - August 26, 2016

Questions Thread - August 26, 2016


Questions Thread - August 26, 2016

Posted: 26 Aug 2016 05:08 AM PDT

This thread is for simple questions that don't warrant their own thread (although we suggest checking the sidebar, the wiki, 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?

Important: Downvotes are strongly discouraged in this thread. Sorting by new is strongly encouraged.

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 today's thread? Click this link!

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

I've started learning Android Development in my Senior year in college and I want to apply Android developer jobs after graduation, Am I being delusional?

Posted: 26 Aug 2016 08:35 AM PDT

So I've started learning android development (mostly online learning) about 2 months ago and at the same time started working for a startup company as a mobile developer intern. I built my first decent application after 2 months but still not able to use networking or API etc. I have exactly 12 months to my graduation and I want to apply for android developer positions. Is it possible to be a android developer in 1 year or am I being delusional?

submitted by /u/funky-monk76
[link] [comments]

Best ad networks as an alternative to Admob banner?

Posted: 26 Aug 2016 07:55 PM PDT

Hi, I am looking into different ad networks, particularly ad mediation networks such as Mopub. This is because I am getting quite paranoid as I completely rely on Admob at the moment, and i've heard many stories of people getting banned from Admob for no reason. My app only uses the 320 x 50 advert banner shown at the bottom of the screen, so does anyone know which networks have this? Thanks

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

Is there an up to date book to hit the ground running with Android development?

Posted: 26 Aug 2016 08:12 PM PDT

As the title suggests, I'm looking for a recent book for learning the Android ecosystem.

I'm not worried about learning Java, I am struggling with layouts, state management, and android specific design patterns?

Constraint layout looks like it will solve most of my issues but I still feel like I'm writing apps in an awkward way. I need a good quality guide to flick through and then reattempt some apps.

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

Android Studio 2.2 Beta 3 Released

Posted: 26 Aug 2016 12:09 PM PDT

Persistence on android - native SQLite + lightweight wrappers vs ORMs.

Posted: 26 Aug 2016 01:00 PM PDT

Dear reddit community,

As android developer, I have been struggling with persistence and everything related to it for almost three years. I have been working on multiple android projects, where each app was used in different area / field. It implies that requirements to persistence mechanism also differed: from short term caching in form of document storage on the disk (storing serialized JSON in files) to databases which intended to be used as long-term offline storage. The problem is that I never felt that solution was right. I will try to explain why exactly it became such a big problem for me by following example. I hope to hear your opinion and learn from your experience of working with storage on android.

Currently, I am involved in the project of building android clients for information system which are intended to be used mostly in developing countries. The primary use case for those apps is to bridge the gap between server, bad internet connection and people. It means that apps will be mostly used in offline setting for quite long periods of time (weeks, maybe months). Since information system is complex, development team decided to split it up into multiple clients on android, where apps will be sharing one library with common components (including models and business logic).

Long story short, we have to deal with 72 fat models which are highly nested and interconnected, and we need to design library APIs correctly (at least to try), since we cannot break them constantly.

ORMs

There is already a bunch of ORMs for android which are almost as fast as native SQLite. For example: DbFlow, ReQuery, Realm, etc. Almost all of them (except Realm) are utilizing Java APT in order to generate schemas and DSL / QL (query language) out of models. They seem to be good solution at first glance, but they are also putting certain constraints on developers, and sometimes performing not as good as expected.

From library / application design perspective, they are certain issues:

  • You have to extend base ORM models: it means you are losing control over API which those library base-models exposing.
  • There is no way you can hide some implementation details from client code. For example you don't want to expose DSL / QL for particular model to applications which consume your library APIs.
  • Memory / Performance issues. Some libraries are abstracting away low-level android APIs, for instance Cursor. In many scenarios you want to consume data from database by small portions if you have many rows / entries in particular table, but you won't be able to because Cursor is hidden somewhere behind the scenes.
  • Threading issues. Attempts to modify same ORM based object can result in unpredictable behaviour.
  • In-memory representation of object can diverge from actual data stored in database. For instance, if you modify two different objects which represent same row and then try to save them, you can end with broken representation of both objects.

Of course, ORMs can also simplify your life, since writing SQL is quite tedious task. They can significantly speed you up as a developer at least during first stages of development. However, in longer term , decision to use ORM can bite you from behind (most of android ORMs are supported only by one person, and at certain stage can be abandoned - it is life after all).

Native SQLite + lightweight wrappers

SQLBrite + SQLDelight.

Approach of building thin abstraction layer around SQLite is very appealing. Almost all of the ORM issues do not exist in this scenario. However, this approach also comes at certain cost: it becomes extremely tedious to work with complex data model by using raw SQL. Especially, if you will take many-to-many relationships between models into account. We will have to create five to six m2m link tables per each entity on average, which pretty fast becomes overwhelming and challenging task if you have to deal with tight deadlines.

There is also similar library to SQLBrite, called StorIO.

I really hope to hear your opinion on this. If you ever have dealt with similar problem and managed to find clean, concise and beautiful solution, please share with it here. I think it can be useful not only to me, but also for a bunch of people out there which have to deal with persistence problems on android.

Thank you for reading this long and boring post.

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

Anybody seeing geolocation issues with WebView v52?

Posted: 26 Aug 2016 11:45 PM PDT

A user just reported, and I confirmed, that navigator.geolocation.getCurrentPosition() is broken in the latest version of the Android System WebView (52.0.2743.98). We're both running Marshmallow on different devices (Nexus, Blackberry Priv).

I tested with other browser apps that also use WebView, and looks like they're all broken. I'm trying to see if there is a systematic pattern for this breakage, or if all users on all devices & all Android versions are affected.

If you are the user or author of a WebView-based browser app, please chime in to let us all know if this is working for you, or if you are already aware of an Android bug report filed against Google. Sample page: Mozilla Developer Network

Details: in WebChromeClient.onGeolocationPermissionsShowPrompt, I correctly call callback.invoke(origin, true, false), and my app has all necessary runtime permissions, but at that point, the webpage gets neither the onSuccess nor the onError callbacks invoked. There is nothing meaningful in the console either, just silence. This exact code used to work for all previous versions.

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

Next steps as an aspiring android dev?

Posted: 26 Aug 2016 11:26 PM PDT

Hi everyone! As a title says I'm looking forward to know the next steps I need in my way of becoming an Android dev.

At this moment I'm a Computer Sciences student on 7th semester, almost out, so I'm looking to develop more my skills on Android development.

My experiences goes from following the Udacity tutorial for the Sunshine app, making a Student-Teacher communication helper and a music player that I still need to finish. The stuff I learnt on this apps are the following (Learnt not mastered):

  • HttpRequests to a server using Android-PHP communication
  • A lot of Asyntask for background stuff (server request, data loading, etc) and yes, I'm really aware that this is bad
  • The use of a service (On the music app)
  • The use of broadcastreciever (like... almost nothing of theory, just practice)

I think that are the important ones, yes, few but better than nothing. As today, outside of Android I'm working for the education system of my state on an dekstop app using Electron/NodeJS so I still need for some real android development experience.

I understand concepts of software engineering and I apply a few and mostly Scrum methodology for the jobs/courses/own apps I'm working on but still, no real experience besides one or two projects

I apologize for my english and really hope my question is on context for the subreddit and someone helps. Thanks a lot if you're reading this!

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

My app's memory usage doesn't decrease when an activity is finished---Memory leaks?

Posted: 26 Aug 2016 11:23 PM PDT

Hello,

I'm currently investigating why the app I'm currently working on uses so much memory.

Imagine an Activity A that displays a RecyclerView of about 20 images. This Activity is started from the HomeActivity. When I first run the app in the emulator, the memory usage shows something like 20 MB, with less than 1 MB being "free" for the app. When Activity A is opened, this usage increases to about 25 MB, while the free memory still is something about 1 MB.

Now what I'm concerned about is the fact that when I finish Activity A (by using the Back button), this 25 MB memory doesn't decrease. It's just that sometimes after about a minute or so, the memory finally decreases to 20 MB again, while the free memory is always around 1 MB. It's as if Android always provides 1 MB free memory for the app, but doesn't have any problems raising the used memory from 20 MB to 25 MB.

Is this a sign of memory leaks? I once read that one symptom would be an always-increasing memory usage whenever you rotate the device (i.e. restart the Activity). What happens with my app is the following: Activity A starts with 25 MB, then I rotate several times, with the memory usage always increasing by about 0.25 MB. When it reaches some kind of arbitrary 27 MB, it suddenly decreases to 24 or 25 MB again.

I'm not sure whether there might be any kind of memory leaks in my code, so what's the best way to spot them? The Activity basically consists of the Activity A and a retained SupportFragment which holds various kind of data (the images' URLs, for instance, but nothing like pointers to Context or something like that), and the RecyclerView which displays those images using Picasso. Is there anything I have to keep in mind when using Picasso regarding memory leaks?

EDIT

I'm aware of Java's indeterminate garbage collection, but I am wondering myself that when I finish() the Activity, should the Memory usage decrease immediately or is the above scenario just a standard sign of Java's GC?

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

MVVM-C A simple way to navigate

Posted: 26 Aug 2016 07:01 PM PDT

This article demonstrates the idea on iOS, but with some imagination one could imagine how to implement it on Android.

http://tech.trivago.com/2016/08/26/mvvm-c-a-simple-way-to-navigate/

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

[Library] - Notification helper. When you want to dismiss some but not with cancelAll() and as well avoid storing id of each notification

Posted: 26 Aug 2016 07:45 AM PDT

Xamarin MvvmCross Dreams 2.0.0 released (Samples and best practices)

Posted: 26 Aug 2016 09:30 PM PDT

Is it against Google Play policy to monetize my app with Affiliate links?

Posted: 26 Aug 2016 08:06 PM PDT

What kind of AD do you use to monetize?

Posted: 26 Aug 2016 07:44 PM PDT

I use

[UnityADs] reward video (It's best earning until now)

[Vungle] reward video (Payment method is very strange. After 3 month, I can get 100% Payment.

[Tapjoy] auto play video (It's worst earning. Many permission is needed but Analytics very good)

[AdMob] banner (It's good, Payment method is easy)

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

No Admob data since 08-19-2016

Posted: 26 Aug 2016 12:56 PM PDT

So I recently decided to revamp some of my apps when I found out I had made some Ad revenue money. I decided to change out the Ad Unit to see if my new design and functionality improved revenue. I have quadruple checked Ad Unit Id and that everything is right.

My ads have been showing since 08/19/2016 but on my admob dashboard I literally have no data. Not even 0s. I have no emails or notices and my account standing is "Open" so I am just wondering if I anyone else is seeing this or if this is typical? When I check Google Play Dev Console I had had downloads and installs all week but on admob not even 1 impression. I just changed out the Ad Unit and updated the APK to see if I can get some data over the weekend.

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

Weekly "anything goes" thread!

Posted: 26 Aug 2016 06:07 AM PDT

Here's your chance to talk about whatever!

Although if you're thinking about getting feedback on an app, you might want to wait until tomorrow's App Feedback thread.

Remember that while you can talk about any topic, being a jerk is still not allowed.

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

`Rxify` — a simple spell for complex RxJava operators (Part -3)

Posted: 26 Aug 2016 12:33 AM PDT

What to do with API Keys?

Posted: 26 Aug 2016 10:01 AM PDT

Is there a best practice for storing API keys in an app? I've heard proguard obfuscation can be beaten fairly easily. I want to be sure the keys can't be found after decompilation.

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

[Brainstorm] Struggling with long builds (clear)

Posted: 26 Aug 2016 12:18 AM PDT

Hope it's only me who facing very (!) slow builds of project with multidex enabled (even when targeting on dev build android 23+)

I feeling bad of my Macbook Pro 2014, it becomes so hot so i can grill beef on it.

May be we can put our wits together and find solution on how to improve speed of build on (Okay), dev builds?

i had and idea what if we divided project into modules and generated jar for main (compiling module), like common entities & common libraries, so it will decrease some time.

submitted by /u/O3uk
[link] [comments]
Thanks for reading my news about Questions Thread - August 26, 2016 at my blog Custom Droid Rom if you want too share this article, please put the resource, and if you think this article is very usefully dont forget to bookmark this site with CTRL + D on your keyboard to web browser.

New and Hot Article's :

Note: only a member of this blog may post a comment.