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
Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Thermopyle posted:

I'm excited to get back into Android dev with this.

React for the web is fantastic.

The dev cycle being (usually) edit/reload/test in a matter of seconds (and without having to necessarily redo a bunch of steps in your app) is so much nicer. I also think the Chrome developer tools are better than the Android Studio/etc. ones, but not everyone agrees.

Volmarias posted:

Manufacturers make mistakes that break CTS, then push out an update never several months after public discovery. There's nothing particular to this one, I just advise caution on assuming that a manufacturer hasn't invalidated a fundamental assumption in a place like this. Look out for some devices that always return zero here, I've seen that happen for sure, I haven't seen an otherwise inaccurate timestamp however.

Interesting, thanks. I guess it's also annoying that you can't reliably find out how old the fix is, since there's no way to get the current time as seen by the location system. (Which seems like the whole point of the fix time, but I guess it has other uses as well.)

Adbot
ADBOT LOVES YOU

Glimm
Jul 27, 2005

Time is only gonna pass you by

Subjunctive posted:

The dev cycle being (usually) edit/reload/test in a matter of seconds (and without having to necessarily redo a bunch of steps in your app) is so much nicer. I also think the Chrome developer tools are better than the Android Studio/etc. ones, but not everyone agrees.

Yeah, I have a slight aversion to JavaScript but the live reload is really slick and the idea behind React has me really excited.

I'm also hoping React Native for Android somehow hides some of the terribleness of the Android lifecycle from me.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
I read recently that JSX isn't required to work with React, but how recommended is it? I've kinda ignored React because I didn't want to bother learning "something-like-Javascript-but-not-quite" but now that I know I can use plain vanilla Javascript, and now that React Native is out, I'm considering playing around with it.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

quote:

Interesting, thanks. I guess it's also annoying that you can't reliably find out how old the fix is, since there's no way to get the current time as seen by the location system. (Which seems like the whole point of the fix time, but I guess it has other uses as well.)

This was actually an obnoxious bug for me to deal with when writing GPS Notification. OEM sends two callbacks at a time (hell if I know why), one with the correct time and one with 0 and filled with junk. My solution was to discard any fixes with zero. Then, you get callbacks for like two minutes since the last actual fix but with the time that fix was at. OK, fine, discard fixes older than a minute.

Then, you get the carrier giving your phone a time a couple minutes in the past, so the fixes are correct but there's a constant delta. Uggghhhh OK fine compare the timestamp against timestamps on the previous fix.

Again, everything is technically up to spec, but weird behaviors cause problems.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Karthe posted:

I read recently that JSX isn't required to work with React, but how recommended is it? I've kinda ignored React because I didn't want to bother learning "something-like-Javascript-but-not-quite" but now that I know I can use plain vanilla Javascript, and now that React Native is out, I'm considering playing around with it.

Either way is completely supported...at least on web. I haven't looked at React Native yet.


edit: I finally got around to looking at it and...only OS X is supported. :/

Thermopyle fucked around with this message at 02:17 on Sep 15, 2015

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Thermopyle posted:

edit: I finally got around to looking at it and...only OS X is supported. :/

I expect that to change pretty quickly, I think it's just build mechanics.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
So we've built most of an iOS app in Xamarin and I'm now working on rebuilding the UI in Android, which is my introduction to Android programming. That said:

Am I retarded, or is Android's styling setup retarded?

The XML state list indirection for choosing colors and drawables based on things like button_state is great (mostly). Does that exist for anything else like setting text sizes or elevation? For the life of me I can't find anything like it, so now I'm in this weird position where some control properties are specified declaratively in XML while others are handled imperatively in code.

Also, the state lists seem to only work 1 level deep. So, for example, let's say I want a button with rounded corners that changes only its background color when pressed. I can't just set up a color state list and reference that in a single drawable style, I instead have to create a drawable state list referencing a bunch of mostly duplicated drawable XML files that only differ in the background color they reference.

Sorry if this just sounds like rambly ranting, I've just been bashing my head against this Android styling stuff trying to create something that actually has any code reuse. I'm sure half of what I'm saying is wrong and I haven't found The Right Way.

Bognar fucked around with this message at 20:42 on Sep 15, 2015

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Yeah it's a bit of a pain and I'm wrestling with UI stuff myself. I don't know about your stuff specifically, but maybe this will help?
http://blog.supenta.com/2014/06/15/how-to-avoid-headaches-with-android-themes-and-styles/
It's a pretty comprehensive overview of how themes and styles work, and how you can stash common attributes in a style so you're not repeating yourself. Maybe you're already familiar with it or it's no use for states, but worth a look I guess

MrPablo
Mar 21, 2003

baka kaba posted:

Yeah it's a bit of a pain and I'm wrestling with UI stuff myself. I don't know about your stuff specifically, but maybe this will help?
http://blog.supenta.com/2014/06/15/how-to-avoid-headaches-with-android-themes-and-styles/
It's a pretty comprehensive overview of how themes and styles work, and how you can stash common attributes in a style so you're not repeating yourself. Maybe you're already familiar with it or it's no use for states, but worth a look I guess

Thanks, that link is great.

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

rock2much
Feb 6, 2004

Grimey Drawer

kitten smoothie posted:

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

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

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?

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.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Humble Bundle has a hell of a deal right now for potential Android game developers: https://www.humblebundle.com/weekly

$12 gets you GameMaker Pro ($150) PLUS the Android Export Module ($300). You also get the source code of a dozen or so games created in GameMaker (including Stealth Bastard Deluxe and Super Crate Box) to pore over and learn from.

It almost seems too good to be true, but it's the real deal. Forget about actually downloading anything today, though - YoYo's site is getting absolutely hammered with the new traffic and it's impossible to login to register the code you get from HB.

IAmKale fucked around with this message at 23:46 on Sep 18, 2015

rock2much
Feb 6, 2004

Grimey Drawer
I think I did a dumb thing, but I don't know how to fix it.
I'm following a lesson plan to make an app in android studio, and got so turned around that I said gently caress it and remade the whole project in another directory. I can open/save/run just fine, but when I try to use android studio to push the files to github, it's only sending my 6 java files.

I tried to use these directions to select other files for upload but it's not working: https://www.londonappdeveloper.com/how-to-use-git-hub-with-android-studio/

Edit: fixed it. Deleted all the .git folders in my project, turns off VCS and started from scratch.

rock2much fucked around with this message at 21:32 on Sep 21, 2015

Sereri
Sep 30, 2008

awwwrigami

I'm thinking about ripping out the backend of Awful.apk and replacing it with a new one (that actually does what it should). Maybe ripping out the view apart from the layouts too.

What is currently being used for networking, what are the current trends for app architecture?

To give an idea, current Awful.apk basically sends a request via some slighty customised Volley and saves the processed data to a sqlite database (for offline browsing for example) . It then outputs the data via contentproviders to the webview. I think, I'm currently not at a computer.

So, what be a current way to build something like that?

Glimm
Jul 27, 2005

Time is only gonna pass you by

Sereri posted:

I'm thinking about ripping out the backend of Awful.apk and replacing it with a new one (that actually does what it should). Maybe ripping out the view apart from the layouts too.

What is currently being used for networking, what are the current trends for app architecture?

To give an idea, current Awful.apk basically sends a request via some slighty customised Volley and saves the processed data to a sqlite database (for offline browsing for example) . It then outputs the data via contentproviders to the webview. I think, I'm currently not at a computer.

So, what be a current way to build something like that?

The Android folks at my company are mostly using Retrofit/OkHttp for web requests. They're moving to RxJava to do more complicated things with their requests. They're manually using ContentProviders / SQLite for storing data.

If you're on the RxJava train SQLBrite (https://github.com/square/sqlbrite) looks neat, but I haven't used it and I'm not sure how popular it is.

Farchanter
Jun 15, 2008
I'm new to OpenGL, so I apologize if this is a really basic question, but right now I have a GLSurfaceView. I'm calling getHolder() to gain access to the surface and then the canvas, but when I call canvas.isHardwareAccelerated() on that canvas within my animation thread, that call always returns false. Why would that be?

Thanks in advance!

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

There's two methods in Surface - lockCanvas() and lockHardwareCanvas(). The docs sez:

quote:

Gets a Canvas for drawing into this surface. After drawing into the provided Canvas, the caller must invoke unlockCanvasAndPost(Canvas) to post the new contents to the surface. Unlike lockCanvas(Rect) this will return a hardware-accelerated canvas.

You'll probably want to go look at that since there are caveats about what you can actually do with a hardware canvas

Farchanter
Jun 15, 2008

baka kaba posted:

There's two methods in Surface - lockCanvas() and lockHardwareCanvas(). The docs sez:


You'll probably want to go look at that since there are caveats about what you can actually do with a hardware canvas

that did the trick, thanks! I wonder if there was a way to do it prior to the Marshmallow SDK, but that's purely academic.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Nah, it wasn't possible before. The gory details are here

quote:

As time went on, and devices with general-purpose 3D engines appeared, Android reoriented itself around OpenGL ES. However, it was important to keep the old API working, for apps as well as app framework code, so an effort was made to hardware-accelerate the Canvas API. As you can see from the charts on the Hardware Acceleration page, this was a bit of a bumpy ride. Note in particular that while the Canvas provided to a View's onDraw() method may be hardware-accelerated, the Canvas obtained when an app locks a Surface directly with lockCanvas() never is.

When you lock a Surface for Canvas access, the "CPU renderer" connects to the producer side of the BufferQueue and does not disconnect until the Surface is destroyed. Most other producers (like GLES) can be disconnected and reconnected to a Surface, but the Canvas-based "CPU renderer" cannot. This means you can't draw on a surface with GLES or send it frames from a video decoder if you've ever locked it for a Canvas.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Hrnnngh new vector drawable support in Android Studio including automatic PNG generation of every dpi for pre-Lollipop, and a Material icon library right there in the IDE

https://www.youtube.com/watch?v=8e3I-PYJNHg

Needs a beta version of Gradle right now (haha no) but :f5:

Glimm
Jul 27, 2005

Time is only gonna pass you by

This is neat, a GitHub repo with a listing of Android development related blogs:

https://github.com/ziem/android-development-blogs

PiCroft
Jun 11, 2010

I'm sorry, did I break all your shit? I didn't know it was yours

I'm tearing my hair out over issues with android styling after an update to android studio/the sdk/both. Our app is supposed to have certain themes for its buttons and its actionbar, but for reasons that escape me, it has stopped applying the text colour to the actionbar title.

Here is the themes.xml:
code:
<style name="OurTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:buttonStyle">@style/ButtonAppTheme</item>
        <item name="android:imageButtonStyle">@style/ImageButtonAppTheme</item>
        <item name="android:listSeparatorTextViewStyle">@style/BlueListSeparatorTextViewStyle</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>

        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/action_bar_color</item>

        <!-- colorAccent is used as the default value for colorControlActivated
             which is used to tint widgets -->
        <item name="colorAccent">@color/btn_accent_color</item>
    </style>

    <!-- Application theme. -->
    <style name="OurTheme" parent="OurTheme.Base">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="android:listSeparatorTextViewStyle">@style/BlueListSeparatorTextViewStyle</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    </style>
styles.xml:

code:
<!-- ActionBar styles ThemeOverlay.AppCompat.ActionBar -->
    <style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
        <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
    </style>

    <!-- ActionBar title text -->
    <style name="MyActionBarTitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/actionbar_text</item>
    </style>
If I comment out the line <item name="colorPrimary">@color/action_bar_color</item> in themes.xml, it removes the custom colour from the title text in the action bar which is fine, its what I expect. However, the text colour defined in MyActionBarTitleText never gets applied.

The Activities that use the custom toolbar have <include layout="@layout/toolbar_basic_layout"/>
and toolbar_basic_layout.xml is defined as:

code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
Our compileSdkVersion is 21 and buildToolsVersion is 21.1.2 and we're testing on a device with 4.4.2. This set up previously worked and I'm not very experienced with Android styling so I'm mystified as to why its refusing to work as it did before.

Farchanter
Jun 15, 2008
is there a clear guide anywhere on how to import libraries like appcompat into an Eclipse Android project? Whenever I try to run mine it fails because of the missing library, despite the build running cleanly and the library project being in the workspace, and I haven't been able to help myself online so far. Thanks!

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

There's a guide to building a library project (appcompat is the example) on the developer pages

Any reason you're using Eclipse though? It's been dropped for any further updates, and doing this kind of thing is a ton easier in Android Studio (you just add a line to a config file)

Farchanter
Jun 15, 2008

baka kaba posted:

There's a guide to building a library project (appcompat is the example) on the developer pages

Any reason you're using Eclipse though? It's been dropped for any further updates, and doing this kind of thing is a ton easier in Android Studio (you just add a line to a config file)

Thanks! And mostly because I couldn't get it running in either environment, and I'm much more comfortable navigating Eclipse than IntelliJ. That was going to be the next phase of the operation.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Yeah I felt the same, and I had some massive headaches importing an existing project and getting Gradle working, but once it's up and running properly it's nice. You're probably worth doing it sooner rather than later!

Mezzanine
Aug 23, 2009
My Android developer team members have been dragging their feet moving over to AS, so I have no choice but to take the initiative and get all of our projects working in Gradle. Just about there, though. The whole "flavors" thing is a a godsend since the majority of our apps run on a dual-config "staging / production" structure, and it makes it a cinch to have Gradle spit out an APK of either version. Plus, I can use the same Gradle commands in my Jenkins builds to do the same thing.

Amethyst
Mar 28, 2004

I CANNOT HELP BUT MAKE THE DCSS THREAD A FETID SWAMP OF UNFUN POSTING
plz notice me trunk-senpai
I know nothing at all about android but I've been handed some ancient test script to try and fix quickly

The problem I'm having is launching an activity in the emulator using a command line. I've been given an APK and have access to nothing else. No code.

So far here's what I've done:

aapt dump badging MyApp.apk

This gave me the following:
launchable-activity: name='com.company.myapp.activities.SplashActivity'

So it seems I'm meant to plug that activity name into adb, the problem i'm having is the format for the activity/package name. Here's what I'm getting:

#:adb shell am start -n com.company.myapp.activities/.SplashActivity
Starting: Intent { cmp=com.company.myapp.activities/.SplashActivity }
Error type 3
Error: Activity class {com.company.myapp.activities/com.company.myapp.activities.SplashActivity} does not exist.


Is there something obvious I'm doing wrong here?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
The application package name is probably com.company.myapp, not com.company.myapp.activities, although it's kind of poor form of them to put their activities into their own package. You'll want to do -n com.company.myapp/com.company.myapp.activities.SplashActivity

Amethyst
Mar 28, 2004

I CANNOT HELP BUT MAKE THE DCSS THREAD A FETID SWAMP OF UNFUN POSTING
plz notice me trunk-senpai

Volmarias posted:

The application package name is probably com.company.myapp, not com.company.myapp.activities, although it's kind of poor form of them to put their activities into their own package. You'll want to do -n com.company.myapp/com.company.myapp.activities.SplashActivity

I think I tried that one. I'll systematically try a bunch of permutations tomorrow.

Thanks for the reply!

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Volmarias posted:

it's kind of poor form of them to put their activities into their own package

Why is that? I came across something else that said that recently, but didn't say what problem it avoided. I'm just getting back into Android development, so these sorts of gathered lore are interesting to me.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Subjunctive posted:

Why is that? I came across something else that said that recently, but didn't say what problem it avoided. I'm just getting back into Android development, so these sorts of gathered lore are interesting to me.

There's no technical reason to do it or not to do it. I just feel like you shouldn't segregate your code out of the top level package for your project. That said my app does exactly that, but it's for build reasons alone, not by choice.

Regarding the intent to start your activity, you should verify what the packagename is for your application via aapt dump badging, and make sure that your explicit intent uses that. Your application packagename might be something totally bonkers and unrelated.

You may also wish to do adb lolcat ActivityManager:V *:F and then start your activity via the device launcher, which might be enlightening.

Doctor w-rw-rw-
Jun 24, 2008

Subjunctive posted:

Why is that? I came across something else that said that recently, but didn't say what problem it avoided. I'm just getting back into Android development, so these sorts of gathered lore are interesting to me.
Same reason it'd be weird to put classes, interfaces, and enums each in different packages – your taxonomy should be concerned with organizing major functionality, experiences, or some other sort of meaningful separation. (Opinion)

If you categorize by activities, exploring cross-package dependencies as a heuristic to grok code one major piece of functionality at a time suddenly becomes a lot less consistently useful or predictable.

b0lt
Apr 29, 2005

Subjunctive posted:

Why is that? I came across something else that said that recently, but didn't say what problem it avoided. I'm just getting back into Android development, so these sorts of gathered lore are interesting to me.

One reason is that the R class gets generated in your application's package name's package, so if you want to use it in a class that's in a different package, you need to explicitly import it.

PiCroft
Jun 11, 2010

I'm sorry, did I break all your shit? I didn't know it was yours

What android sdk update was it that set all button text to default to ALLCAPS? I released a build of our app a short time ago, about a week, and the buttons were all normal. I did an SDK update recently and now the build has all its buttons in ALLCAPS.

Also, why would Android make this change? What a load of nonsense.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

The Material / AppCompat themes have all-caps buttons, did you just switch to those recently?

PiCroft
Jun 11, 2010

I'm sorry, did I break all your shit? I didn't know it was yours

baka kaba posted:

The Material / AppCompat themes have all-caps buttons, did you just switch to those recently?

I don't believe so. I haven't touched the theme/style of the app for a few months. We certainly haven't switched over to material and we've been using appcompat for a while, certainly during the time we had our last release without the all-caps.

PiCroft
Jun 11, 2010

I'm sorry, did I break all your shit? I didn't know it was yours

Gah nevermind - as it turns out it wasn't to do with the SDK, but something else.

Adbot
ADBOT LOVES YOU

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

The gah of a coder who's learned the terrible truth

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