Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
kitten smoothie
Dec 29, 2001

Is the RecyclerView the new blessed replacement for ListView going forward? If nothing else it's nice that you finally can use it for horizontal scrolling lists.

Adbot
ADBOT LOVES YOU

kitten smoothie
Dec 29, 2001

Good News, from the people who bring you Google Play Services

quote:

As we’ve continued to add more APIs across the wide range of Google services, it can be hard to maintain a lean app, particularly if you're only using a portion of the available APIs. Now with Google Play services 6.5, you’ll be able to depend only on a minimal common library and the exact APIs your app needs. This makes it very lightweight to get started with Google Play services.

:toot:

kitten smoothie
Dec 29, 2001

There's multi-dex support with the latest Android gradle tooling, though I don't know how reliable it is.

Also the new Play Services SDK now lets you individually select subsets of dependencies based on functionality, so you don't have to include a jar with 20K methods in it.

kitten smoothie
Dec 29, 2001

hooah posted:

Hmm. I originally expected to need to do something with the tap event, but the answer didn't mention it (although it is done with the appcompat library, but I wouldn't think that would change that much), and the guy on StackExchange who was helping me was the one who said that event would be handled by ShareActionProvider. In any case, I thought that overriding onOptionsItemSelected would handle the tap on the "Share" action bar item; is that not the case?

Don't override onOptionsItemSelected, let the action provider do all the work for you.

Get a look at this doc, this should be more clear. I don't see your menu.xml, did you specify the action provider there? That may well be why you're pulling back a null.

Once you've done that, do as you originally had been doing: pick out the action provider in onCreateOptionsMenu once you've inflated the menu, and then you set the share intent on the action provider.

kitten smoothie fucked around with this message at 01:00 on Jan 3, 2015

kitten smoothie
Dec 29, 2001

Trying to grok rxjava by incorporating it into a side project I'm building here. I'm putting together a streaming radio player. I've got a JSON backend I'm hitting with Retrofit that pulls down information about what's "now playing."

The main activity for the app should be getting this info periodically (let's say every 60 seconds), so if you've got the app foregrounded you're seeing a rough approximation of what's on the air. If you're backgrounded and playing music, I want to have the info appear in the notification (presented by a player service) and be updated periodically as well.

I'm seeing an example or two that define a singleton class that sets up a BehaviorSubject and periodically post updates at it. Then the individual consumers (i.e. my player service and my activity) can subscribe on this. Since the BehaviorSubject emits the latest-seen item observed, subscribing means you get the last known "now playing" value right away. Is that the best/right way to accomplish what I'm trying to do here?

kitten smoothie
Dec 29, 2001

Is there any on-device way to simulate a poo poo network? I know you can do this in the official emulator, but I want to do this on a real device. If it needs to be rooted, that's fine, my development device already is.

I like how iOS has the Network Link Conditioner built into the phone. I'm almost about to just go buy a prepaid T-Mobile SIM and lock the phone to EDGE only.

kitten smoothie
Dec 29, 2001

Tunga posted:

My understanding is that OTAs now checksum the entire system image to verify that it isn't modified so it wouldn't make much sense if it could ever be modified by the system running. But I don't actually know that as a fact.

From looking at the OTA update scripts and the recovery source, it looks like it actually computes a SHA1 hash of the filesystem superblock, and validates that against a known value to say "hey you remounted this r/w, re-flash to update." Then before patching it also checks a combined hash of all the parts of the image it cares about patching, I imagine just to be sure. The new OTA scheme literally patches chunks of the block device rather than the filesystem.

As I understand it the act of mounting the filesystem r/w will update the mount time in the superblock, which breaks the first hash. So even if you were to have restored the file structure of the system partition after modifying it, or you did nothing at all but mount the filesystem r/w once and then unmount it, the validation will fail.

So we can then figure from this that the system partition shouldn't be different from boot to boot, or from device to device, unless it was mounted r/w on boot.

kitten smoothie fucked around with this message at 17:10 on May 11, 2015

kitten smoothie
Dec 29, 2001

Welcome to mobile in 2015, mobile operating systems try to obscure the concept of files away and represent things as objects and activities.

A document in an app is just that, and the user isn't meant to know or care about anything lower level than that. Apps can provide documents and content to other apps through defined interfaces but the concept of a file lying around somewhere named blahblah.doc doesn't surface.

Personally I agree with the idea, if you've got to open an actual filesystem browser on a phone then something has gone horribly wrong.

kitten smoothie
Dec 29, 2001

Design support library, with things like FAB, snackbar, etc. Thank loving god.

kitten smoothie
Dec 29, 2001

Here's a demo of all the design support library hotness.

https://github.com/chrisbanes/cheesesquare/

Also, there's a bug with the FAB as shipped in the support library. Looks like you need to set app:borderWidth="0dp" if you don't want your poo poo to break on some devices. The bug is evident even in the demo I linked - on lollipop the FAB's elevation doesn't render right.

kitten smoothie fucked around with this message at 18:11 on May 29, 2015

kitten smoothie
Dec 29, 2001

speng31b posted:

The only weird and potentially hacky thing I'm doing right now is intercepting the analytics referrer broadcast on app install so you can get "install time" project sharing - basically if you click one of my project share links and follow through to install, it'll use the referrer to load in that project on startup so you can actually share projects from start to finish with a user who's never installed the app before.

I wouldn't call that hacky, you've basically implemented the exact same "receiver-side" code you'd use with Google's new app invite system -- you create an invite intent with a deep link, the framework does the rest, and your analytics referrer has the deep link for you to process.

https://developers.google.com/app-invites/

kitten smoothie
Dec 29, 2001

It looks to me like one activity where you select from a list of workout routines, and another activity where you just have a timer that counts down and resets.

I'd say one person could work on the latter, and the former would be a good candidate for pairing. I'm imagining maybe bundling the workout list as a json file in the app bundle and then rendering it in recyclerview/listview.

kitten smoothie
Dec 29, 2001

Also never heard of that library. Okhttp's github repo includes a nice example of doing a multipart post from the contents of a File, so I'd just probably start there.

kitten smoothie
Dec 29, 2001

hooah posted:

I want to (for the time being) display the accelerometer data on the phone's screen. However, I don't know what to search for on the developer website. I thought "text", but that seems to find things related to input. I tried browsing through the API guide, but the User Interface portion didn't have anything about displaying information or output. What am I looking for?

Look into putting a TextView in your layout, and setting the text on it.

kitten smoothie
Dec 29, 2001

Yeah, doing I/O on the main thread is a no-no, so don't do that.

What I would do is instantiate a HandlerThread, get its Looper, and create a Handler from that. Save that.

Then when you get a new measurement, you post a Runnable onto the Handler, and that Runnable's work is to trigger writing the line to the file so it happens off the main thread.

kitten smoothie
Dec 29, 2001

baka kaba posted:

That's something I've wondered about - there's a few options for this kind of thing, like making an Executor with a single thread, or even spinning up a raw thread and just dropping data into a blocking queue. Is there a preferred way to handle simple, repetitive tasks like this?

Truth be told if I were really to implement this, I'd probably just implement the sensor stuff as an rxjava observable, and then observe on Schedulers.io() so you get a thread pool for free that's reserved for I/O-bound work.

kitten smoothie
Dec 29, 2001

Yeah, I've had this happen before and it usually seems to be a hosed up build in some regard. Cleaning and rebuilding has usually solved that for me.

kitten smoothie
Dec 29, 2001

Setters won't do it because you'll still be invoking those on the secondary thread.

code:
Handler mainHandler = new Handler(context.getMainLooper());

Get yourself a Handler for the main thread like that and then post a runnable for the UI update.

kitten smoothie
Dec 29, 2001

If you're using the constructor to pass forward the values to put in the UI, then that approach requires a new object to be created too because you're going to have different values every time. So it's moot really, the approaches just differ in terms of convenience for the developer.

Don't sweat it.

Edit: and unless you want strange and hard to repro concurrency bugs that'll make you rip your hair out, don't even think of trying to reuse that runnable and add accessors for the value if you take the first approach.

kitten smoothie fucked around with this message at 15:55 on Jul 21, 2015

kitten smoothie
Dec 29, 2001

You aren't setting the connection callback so the API client doesn't know who to call the onConnect or onConnecitonFailed on. Check this out from Google's example, specifically this chunk:

code:
mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();

kitten smoothie fucked around with this message at 23:52 on Jul 27, 2015

kitten smoothie
Dec 29, 2001

Oh, and don't forget that the patch didn't fully patch the problem.

I'm really curious how many full time Android developers carry iPhones as their personal device, because we have a bigger window into the sausage factory.

kitten smoothie
Dec 29, 2001

Subjunctive posted:

Yeah, I've been following Stagefright stuff since I got back into Android security recently. It's a beaut. There are always going to be devices that will never be patched (including iPhones), of course.

At least this seems to have lit a fire under Samsung WRT update schedule?

On one hand it's sad that we'll have "Patch Tuesday" for Android, but at least poo poo might start getting patched.

In other news, the 6.0 SDK is up in the SDK manager.

kitten smoothie
Dec 29, 2001

https://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client

They broke the httpclient stuff out into legacy lib so that's an option too. Not to say I'd rely on this past M though. But that might be able to get you compiling against 23 without issues from that.

And yes, your compile SDK must match the Android release level specified in the support/appcompat library versions.

kitten smoothie
Dec 29, 2001

Also Dan Lew's video from Droidcon NYC two weeks ago may come in handy.

https://www.youtube.com/watch?v=Jr8hJdVGHAk

kitten smoothie
Dec 29, 2001

rock2much posted:

I'm just starting in Android (and Java) so I'm hoping this will help a lot. Thanks. Where did you find out about Droidcon? Any other dev events in NYC coming up?

A teammate spoke at Droidcon NYC, so I tagged along. I don't know a whole lot about what else is in NYC, I flew in for the conference ¯\_(ツ)_/¯

There's another Droidcon in SF coming in November FWIW. I found the Droidcon talks to be a whole lot more "useful" and applicable to day-to-day life as an Android developer, as opposed to Google I/O talks.

kitten smoothie
Dec 29, 2001

Anyone else going to the Android Dev Summit in MTV in a couple weeks?

kitten smoothie
Dec 29, 2001

Why use git on top of Drive when you can just use a hosted git repo? It seems like storing a git repo on top of Drive is asking for janky behavior, at best.

kitten smoothie
Dec 29, 2001

re testing chat:

I've found Robolectric to be more trouble than it's worth in some places. In my experience it hated finding resources when it came to build flavors, and also any update to the library often brings in a ton of breaking changes that lead to burning a day on yakshaving your tests. Also the shadow implementation doesn't necessarily jive with what's actually going on in the Android core and unlike instrumentation tests you can't test breaking changes between different API levels.

Google put together a code lab that's pretty handy in terms of illustrating architecting for testing, and doing a combination of JUnit tests and instrumentation tests (and also now Android Studio 2.0 breaks down some of the walls between these two, which is nice). Basically get all your business logic out into classes that don't implement the Android SDK, and then test those using plain old JUnit. Use DI to feed mocks into those implementations so you can control what's going on under testing.

Similarly, on the flip side, use Espresso instrumentation tests to test your views, and feed it mocks of your business logic so you can both tee up mock data to populate your views, and test interactions confirm that your UI is calling into that correctly.

https://www.code-labs.io/codelabs/android-testing/index.html?index=..%2F..%2Findex

kitten smoothie
Dec 29, 2001

I've been meaning to look into Mortar/Flow, or something similar, for my product at work. Fragments are such an ugly loving hack; it seems like a good idea up until you run into bugs introduced by the additional layer of lifecycle/state.

kitten smoothie
Dec 29, 2001

The mess of LeakCanary exceptions for Samsung garbage is also impressive, just ctrl-f + Samsung and weep.

Specifically, check out where they've modified AOSP code and added static Context fields. How could that possibly go wrong?

There's also this crash with RxJava that we only saw on some tiny subset of Samsung devices and we could never repro it in-house with the same phones. All we could think of was it was maybe one specific carrier build that got screwed up, or they aborted an OTA.


We recently decided to go to minSdkVersion 19 with our next release since the userbase below that is practically insignificant, so at least that's a few more bad Android neighborhoods I can avoid.

It's nice when your customer base is one that generally upgrades their phones every two years, the downside is that they upgrade to the next Samsung.

kitten smoothie fucked around with this message at 19:34 on Dec 20, 2015

kitten smoothie
Dec 29, 2001

baka kaba posted:

What kind of fragment nesting are you talking about? Like adding fragments to your UI, but each of them might contain its own little ecosystem of fragments?

I assume they're going from the sort of perspective where in iOS a view controller basically owns a view and all the logic that glues it together, and in iOS it's a common pattern to compose multiple view controllers together into one "screen."

It seems tempting to do this with Fragments but you're probably going to find yourself in a world of pain if you do so.

If you're looking into MVP I would consider composing multiple presenters and separate views in one activity, as opposed to nesting fragments.

kitten smoothie
Dec 29, 2001

I've mainly run into lifecycle/state related issues, and those just get even worse once you start getting into nested fragments.

The aforementioned Square blog post is pretty good. I've bumped into weird bugs that are all attributable to the things they point out here.

kitten smoothie
Dec 29, 2001

fleshweasel posted:

I would like to set the map to show the user's location on load. Do I need to asynchronously get a GoogleMap and a GoogleApiClient and then provide both to the map presenter so it can handle setting the map location to the user's location?

If I were to design this I wouldn't want my presenter to know what a GoogleMap or a GoogleApiClient is, I'd just firewall it off with interfaces and some thin wrappers.

I would probably create a custom view class to embody the whole map view and have it implement some kind of MyCustomMapView interface, have the presenter know about that, and all of the things that would affect the GoogleMap or map view would be done by calling MyCustomMapView interface methods.

Similarly same thing with the GoogleApiClient, maybe a thin wrapper around that and again have it implement some MyApiClient interface.

It sounds like a little bit extra work but by having the presenter not know directly what those are, now you can mock out those dependencies in tests (since you can use mocks to mock "an instance of some arbitrary class that implements an interface"). Then you can confirm, through tests, your presenter's business logic like "we should request a location from the API client, and when we receive it, we should update the map accordingly." The best part is this that by keeping the Google/Android frameworks from poisoning your presenter, your tests can be pure JVM tests and you'll love this because instrumentation tests on a device/emulator take like 10x longer to run.

kitten smoothie fucked around with this message at 16:53 on Jan 22, 2016

kitten smoothie
Dec 29, 2001

I haven't tried it but Lyft also open sourced a library for doing some of your fragment-ish things (backstack, etc) without fragments.

https://github.com/lyft/scoop

kitten smoothie
Dec 29, 2001

speng31b posted:

I wish. One of the problems with it is how much misinformation there is floating around, even in Google's own docs and examples.

Your best bet might actually just be to glance through the approaches Google uses in its sample repos -

https://github.com/googlesamples?tab=repositories

They actually document Android a lot better in code than plain English.

The code labs at code-labs.io are really helpful too. The Google samples are excellent as well, and some of them illustrate other good practices (the fingerprint auth example for instance uses Dagger).

kitten smoothie
Dec 29, 2001

Newf posted:

Is anyone able to tell me at a glance what platform this cross-platform (iOS, Android, Blackberry) app is built with? I'm assuming it's a phonegap / cordova thing, but it's be nice if someone who knows what's up would say so.

Looks like it's just a WebView wrapper around a JQuery Mobile site, and was created using this https://www.biznessapps.com/ (at least from what I could tell running it through apktool).

kitten smoothie
Dec 29, 2001

speng31b posted:

http://pullappsinc.ca/home.html lol "hypertext" "information" "transfer" "MOBILE APP."

I'm the $6000 webview wrapper

kitten smoothie
Dec 29, 2001

Subjunctive posted:

Does anyone in this thread use Stetho (http://facebook.github.io/stetho/)? Looking to gather feedback on it from people outside FB who use it.

Yeah, it's in our team's debug builds. I've set up the OkHttp interceptors for monitoring network traffic and it's often easier to use the view inspector versus futzing with Hierarchy Viewer. Also nice for going and editing text view contents real time and making sure that crap like word wrap works like I want.

I don't know a whole lot if the rest of my team uses it but I find it handy.

kitten smoothie
Dec 29, 2001

Yeah, data binding looks to me like it's way too easy to wind up with layouts that look like JSP

Adbot
ADBOT LOVES YOU

kitten smoothie
Dec 29, 2001

Chas McGill posted:

Is there a good book or site on starting android dev for people with a bit of existing Java knowledge? I'm thinking of making an app for my final degree project. I'd be particularly interested in graphics and UX related stuff.

Do the Udacity Android Fundamentals course. You don't have to pay if you don't want a certification.

This course is developed in conjunction with Google. The other docs Google does are outdated and crappy.
the Big Nerd Ranch book is also ok but truth be told the Udacity stuff will get you learning by doing.

edit: after 14 years on this forum i have finally made the markdown is not bbcode mistake

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply