Questions Thread - May 23, 2016

Questions Thread - May 23, 2016


Questions Thread - May 23, 2016

Posted: 23 May 2016 05:11 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!

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

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

Weekly "who's hiring" thread!

Posted: 23 May 2016 06:32 AM PDT

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

Here is a suggested posting template:

Company: <The company>
Job: <Title>
Location: <City, State, Country>
Allows remote: <Yes/No>
URL: <Link to the listing URL>
VISA: <Yes/No>

Feel free to include any other information about the job.

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

I whish that more devs implemented this feature. It's very handy if you mainly use one app to share stuff...

Posted: 23 May 2016 03:39 PM PDT

Starting a new Rx library? Remember to respect the Observable lifecycle. Some tips.

Posted: 23 May 2016 04:49 PM PDT

Every other day there's a new Rx wrapper, I'm guilty of several of them myself, so here are some common advice I have to give to most projects I code review.

1.- Avoid Observable.create() when possible. If you're creating a wrapper there's a high chance you just have to call the methods and forward the result, so use Observable.fromCallable() instead.

2.- If your Observable returns 1 result, use Single instead. It's a subset of Observable specifically for that case. If your Observable doesn't return anything, use Completable instead. They can be converted to Observable by customers anyway so you might as well be explicit about the lifecycle of your operation.

EDIT: /u/pandanomic points here that Single handles cancelling via takeUntil as an exception, so it may not fit all use cases.

3.- Now, once you make sure you have to use Observable.create():

  • Defer the creation. If you're plugging in some listener to a third party there's a 100% chance you don't need the results while nobody is subscribed or else you'd be using a Subject. Use Observable.defer(() -> Observable.create(...)) for that.

  • Respect unsubscriptions. Do not forward to onNext, onError, or onCompleted if you haven't checked for !subscriber.isUnsubscribed() in the same line. Also do the check before forwarding, not at the top of the create function, because you want it to not forward the operation and not cancel it.

  • Clean after yourself. You probably do not need that Context past initialization so don't retain it. Your listeners have to be removed. Release any strong reference you hold to sensible elements, like literally anything on the Android framework, because most of them do hold strong references to Context and can leak. Do it by adding a subscription to the subscriber and nulling or removing the references there.

  • Clean up only when necessary. Your Observable.create() is called once when called, not per subscription, which means that if you disconnect any 3rd party listeners on unsubscription as described above, they never come back because your Observable is single-use. Fix it by either using defer (creates multiple observables) or using the operator share (shares same observable to multiple subscribers).

4.- Write tests for your Observable internal lifecycle, not only the user-facing success/error, specially if you're using create. They're good for documentation, as sometimes samples may be too contrived to reflect some design choices.

5.- Observable<Boolean> is a bad design most of the time. An incomplete operation is a failure, so Completable may express the problem/solution better. Let the library users handle them using any of the error recovery operators.

EDIT: There's a chance I've made a mistake or several above, so constructive additions are welcome and I will edit them in.

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

Eight Ways Your Android App Can Leak Memory - NimbleDroid

Posted: 23 May 2016 06:14 AM PDT

Ported my RxJava Firebase wrapper to the new version

Posted: 23 May 2016 12:16 PM PDT

Upgraded my older library RxFirebaseAndroid to the new version from Google. Called RxRoboBase because RxGoogleFirebaseAndroid would've been even worse.

Right now it has main Firebase and Firebase Auth features in a single module, but I'm planning on splitting them the same way Firebase did. I'll be adding Firebase Analytics and Firebase Storage as we use those in our product. The library is a bit sparse, right now it's pretty much 8 public methods, since I just added what we're using now.

If you want to contribute, this one actually has tests, but you'll need an emulator and a Firebase repo set up in the new console.

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

Getting from ⭐️⭐️ to ⭐️⭐️⭐️⭐️⭐️

Posted: 23 May 2016 07:31 PM PDT

What are your thoughts after using the new ConstraintLayout?

Posted: 23 May 2016 02:24 PM PDT

I found it to be completely unusable as a tool. I tried even the most simple layouts of vertical textviews and text would appear/disappear randomly, things couldn't be clicked on, constraints wouldn't update, items couldn't be dragged. I understand that it's in preview, but I was wondering if anyone had any positive experience with it yet?

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

Google I/O 2016 Presentation software?

Posted: 23 May 2016 11:02 AM PDT

Does anyone have an idea what kind of presentation software were Googlers using at Google I/O 2016?

There were some mentioning around in time they are using Keynote. I am a little sceptical though all level of control I saw at the sessions to be achieved with Keynote.

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

Monument Valley in Numbers: Year 2. Huge gap in Android and iOS

Posted: 23 May 2016 05:49 AM PDT

From a single developers point-of-view, do you prefer iOS or Android and why?

Posted: 23 May 2016 08:56 PM PDT

I know this is somewhat of a common question, but I'm looking to get a detailed response from you guys. Please give a detailed reason. P.S., I'm aiming this to independent devs who write natively in both languages.

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

Choose your Android crypto

Posted: 23 May 2016 08:07 AM PDT

Can I use the Android Trade Federation Library to save and compress logs in the app and distribute this on the play store?

Posted: 23 May 2016 03:26 PM PDT

I'm still an amateur android programmer and I want to compress and store logcat on an android device so that if the user's app crashes while offline, then his/her device will send the logcat feed when the device comes back online. I started reading about the Trade Federation Library. Something new and different about this to me is that it does not come automatically available. According to the android docs the source is saved in a git branch along with the normal Android source code, but i have to call something like:

$ repo init -u https://…/manifest -b tradefed

to enable the source code. Does this mean any code I use from this library wont be available to the user on their device?

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

My App got rejected from Google Play

Posted: 23 May 2016 10:18 PM PDT

Hello, yesterday, I submitted my first app to Google Play. After a few hours, I get notified that my app was rejected because it uses the word MensaMax in the description. This is in fact an app in the Google Play Store, but also a software to manage the menu of canteens. My app shows the menu of canteens that use MensaMax, but I can't put it in the description because then the app would get rejected. What can I do? I definitely have to mention that my app is only working for canteens that use MensaMax in the description because how else should the user know? Thank you all!

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

Looking for an Android Programming Partner

Posted: 23 May 2016 12:17 PM PDT

I have 1-2 years of Android experience especially in custom drawing on the canvas, custom views, and animations. I'm looking for someone with a similar level of Android exp to work with on a few just-for-fun side projects. I also have an eye for design and can do mockups on Photoshop (I should really switch over to Sketch soon but I just have so many years having worked with Photoshop).

I have a penchant for clean, easy to use, productivity-oriented apps, but I'm pretty open-minded about the type of app to build. It is mainly for fun, after all.

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

10 common mistakes Android app developers make

Posted: 23 May 2016 09:23 PM PDT

Is there any newer streaming(android to vlc) libraries like Libstreaming or newer examples of Libstreaming uses?

Posted: 23 May 2016 10:23 AM PDT

I've tried Spydroid and like 3,4 "examples". They've all been a pain to even open in Android Studio(probably written with Eclipse) and meant for super old versions of Android. Anyone knows a newer versions?

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

How to improve the performance on a RecyclerView with a huge data-source

Posted: 22 May 2016 11:52 PM PDT

Hi there,

I have a RecyclerView that shows thousands of records, and although I implemented every optimization I knew and every trick I came across, on old devices like a Nexus 7 2012 the fragment that holds the RecyclerView takes over a second to show up because the garbage collector is triggered several times.

Considering the scrolling performance is very satisfying, I don't think the problem is the inflate process: after all, the whole point of using RecyclerView is to inflate only a few rows and reuse them, and on top of that, the row-layout is very simple, basically just a handful of TextView.

I believe the problem is that the thousands of POJOs that are being retrieved from the Realm database and kept in the adapter, are filling up the device's memory.

One of the first solutions that you may be thinking of is lazy-loading, but unfortunately that solution doesn't fit one of the app's hard-requirements: I have to get all the data from the get-go because the RecyclerView has to be searchable right-away.

Having the RecyclerView get the data from the database itself instead of preloading the data might be an idea, but I'm not sure about the implementation. Would you point me to the right direction?

What other solution do you think may be viable to improve the situation?

Thanks in advance.

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

Admob & Firebase and extra permissions.

Posted: 23 May 2016 07:58 AM PDT

Recently I Admob started asking to link with firebase, and when add ing a new ad unit the instructions tell you to use

compile 'com.google.firebase:firebase-analytics:9.0.0' compile 'com.google.firebase:firebase-ads:9.0.0' 

What isn't explicitly documented is that firebase adds these permissions to your app:

ACCESS_NETWORK_STATE permission.WAKE_LOCK com.google.android.c2dm.permission.RECEIVE 

I don't like the idea of asking for these extra permissions just to have analytics and ads.

Does anybody know if there is a way of not having these extra permissions? are there more slimmed down dependencies?

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

Vulkan Support in Android N

Posted: 23 May 2016 03:01 AM PDT

With google is supporting Vulkan API natively anyone know if google will redo the entire android UI with Vulkan. I heard Samsung have created a touchwiz launcher using Vulkan to help the butteriness and save battery since Vulkan is more processor efficient. If they did I'm sure they can really make the whole UI alot smoother and get rid of alot of little jitters here and there and also provide a base where all apps running atop android automatically are rendered using Vulkan. Im not sure if this is even technically possible ..

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

How can I work with images and files without immediately running out of memory?

Posted: 22 May 2016 11:54 PM PDT

I'm working on something that needs to make files into byte arrays, and edit bitmaps at the same time. However, whenever anything is loaded, it runs out of memory.

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

Rewarded Surveys: The Answer To An App Publisher’s Revenue Prayers?

Posted: 23 May 2016 02:39 AM PDT

Thanks for reading my news about Questions Thread - May 23, 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.