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
Sereri
Sep 30, 2008

awwwrigami

Material Design compatibility guide posted:

The material theme is only available in the Android L Developer Preview. To configure your app to use the material theme on devices running the Android L Developer Preview and an older theme on devices running earlier versions of Android:
  1. Define a theme that inherits from an older theme (like Holo) in res/values/styles.xml.
  2. Define a theme with the same name that inherits from the material theme in res/values-v21/styles.xml.
  3. Set this theme as your app's theme in the manifest file.

Yeah I bet this will catch on very soon.

Adbot
ADBOT LOVES YOU

Glimm
Jul 27, 2005

Time is only gonna pass you by

They'll probably make that setup a default for new apps, at least.

It would be nice to backport the Material stuff so we can just use the exact same theme, I have to believe this is the plan. Right Google? Right?

FateFree
Nov 14, 2003

I'm playing with an alarm application and I want to make the dismiss screen stick around until a specific action takes place. However, you can simply press the home button or restart the phone to get around it now. What are some ways of forcing the activity to remain open?

I was thinking of either:
1) Disabling back button or home button
2) Scheduling a repeating activity unless the action takes place, in which case I cancel it (not sure how to do this)
3) Trying to override the finish/onPause methods to prevent the activity from stopping, if thats even possible.

Any ideas on what would be the best way to accomplish this? How can I ensure that its the same instance of the activity that gets relaunched, if a scheduler is the best option?

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

FateFree posted:

I'm playing with an alarm application and I want to make the dismiss screen stick around until a specific action takes place. However, you can simply press the home button or restart the phone to get around it now. What are some ways of forcing the activity to remain open?

I was thinking of either:
1) Disabling back button or home button
2) Scheduling a repeating activity unless the action takes place, in which case I cancel it (not sure how to do this)
3) Trying to override the finish/onPause methods to prevent the activity from stopping, if thats even possible.

Any ideas on what would be the best way to accomplish this? How can I ensure that its the same instance of the activity that gets relaunched, if a scheduler is the best option?
You want to block the user from using their phone until something in your app is completed? That's not really how things work on Android. You can intercept and prevent the back button from doing anything by overriding onBackPressed() in your Activity, but there's absolutely no way to prevent the Home button from being used to return to the launcher. I can't say with complete certainty but I'm pretty sure #2 isn't possible because there's no way to schedule a task to run X application at Y time, and #3 isn't an option because Android likes to stay in control of an app's lifecycle.

The best way to handle this would be to set up your app to check for completion of "a specific action" in your main Activity's onStart() and then re-display the dismiss screen. You can also use setCancelable() in your dismiss screen (if it's a Dialog) to prevent it from being closed via the Back button or by touching outside of the window.

Tunga
May 7, 2004

Grimey Drawer
Put the alarm sounding part in a service and have it display an ongoing notification. Then bind to the service with the activity and let the user dismiss it via the button / maths problems / whatever gimmick your alarm app has. If the user minimises the app, it'll keep sounding until they go back to the app which they can do either with the task switcher or via the notification. This is how the stock clock/alarm app works.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Tunga posted:

Put the alarm sounding part in a service and have it display an ongoing notification. Then bind to the service with the activity and let the user dismiss it via the button / maths problems / whatever gimmick your alarm app has. If the user minimises the app, it'll keep sounding until they go back to the app which they can do either with the task switcher or via the notification. This is how the stock clock/alarm app works.
I...I have so much to learn :negative:

Tunga
May 7, 2004

Grimey Drawer

Karthe posted:

I...I have so much to learn :negative:
If you've never touched services before, now is a good time to learn because what you're doing here is actually relatively simple and a really good example of when you would use a service to run something in the background and then bind an activity to it. I am not an expert in this stuff but I'm pretty sure this is the most appropriate workflow for what you are describing.

http://developer.android.com/guide/components/services.html

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
There ARE ways to make your UI always be on top, but it's generally not a good thing for you to do.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Tunga posted:

If you've never touched services before, now is a good time to learn because what you're doing here is actually relatively simple and a really good example of when you would use a service to run something in the background and then bind an activity to it. I am not an expert in this stuff but I'm pretty sure this is the most appropriate workflow for what you are describing.

http://developer.android.com/guide/components/services.html
FateFree was the one with the app question, I was just offering up some (seemingly poor) advice. I'm definitely going to start playing around with services, though, as it sounds like one of those things that comes up sooner or later when it comes to Android app dev.

Tunga
May 7, 2004

Grimey Drawer

Karthe posted:

FateFree was the one with the app question, I was just offering up some (seemingly poor) advice.
Ah, yeah, I was on my phone and didn't check the names properly :) .

Regarding list item number two, you can schedule activities to launch at a specific time. It's not a thing you'd normally want to do because that's a good way to infuriate your user, but in the case of an alarm clock app it would be entirely reasonable.

https://developer.android.com/training/scheduling/alarms.html
http://www.steventrigg.com/alarm-manager-create-an-alarm-clock-in-android-tutorial-part-6/

However, you definitely shouldn't use this to constantly pop up an Activity until something happens, that would be terrible.

Tunga fucked around with this message at 19:09 on Jul 9, 2014

kitten smoothie
Dec 29, 2001

Tunga posted:

However, you definitely shouldn't use this to constantly pop up an Activity until something happens, that would be terrible.

Yeah, that sounds like the mechanism this piece of ransomware uses. Background service that just waits 5 seconds after an activity goes away and spawns a new one.

http://labs.bitdefender.com/2014/05/reveton-icepol-ransomware-moves-to-android/

Tunga
May 7, 2004

Grimey Drawer
This is from ages ago but I'm working on this problem again and I'm still trying to decide what the best way to approach it would be.

Tunga posted:

I'm looking at using AccountManager with a custom AccountAuthenticator and SyncAdapter to sync some data with a fairly simple REST interface. The server doesn't support HTTPS or auth tokens so I need to send the username/password each time. Should I have #getAuthToken return the password as a kind of fake token, or should I have the SyncAdapter request the password directly (which will be allowed since it's in the same package) and have #getAuthToken throw an UnsupportedOperationException (or similar)? Both of these break the rules somewhat but I feel that the second option is probably the better of the two since it doesn't expose the user's password to other apps. Or is there a better way to handle this?
Any thoughts?

Kenishi
Nov 18, 2010
Maybe someone can help me figure out what's up with my build.

I've been getting a lot of "class not found" and "NoClassDefFound" errors recently.

My android project in Eclipse imports another Java project and uses some of the classes in that. Till now I've been able to simply go into the Java Build Path on the droid project and add it to the "Projects" and then go to "Order and Export" and check it. However recently when I try to build and run the app in the emulator I'm getting a ton of errors saying it can't find the classes, almost as if they aren't getting exported. Here's the weird part, if you pull the same repo down on my Mac machine and build&run, it works fine! :smithicide:

I've tried tons of stuff. Cleaning, rebuild, reordering exports, deleting/reinstalling eclipse, clearing workspace settings, etc. with no luck.

Some info that might help diagnose the issue. My java project uses maven to build (Droid project doesn't), but I've checked to make sure the classes do build and they are in the folders, again this works on Mac no prob.
JDK version: 1.7.0_02
JRE ver: 1.7.0_55

I'd love to get my windows machine building again, but at this rate I'm half tempted to format and resintall. Any ideas?

Kenishi fucked around with this message at 11:36 on Jul 16, 2014

Volmarias
Dec 31, 2002

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

Kenishi posted:

However recently when I try to build and run the app in the emulator I'm getting a ton of errors saying it can't find the classes, almost as if they aren't getting exported.

That's because they're probably not. If you use baksmali or something similar on the apk, you'll probably find them missing.

As to why, the answer is usually Because Eclipse. I'm not sure what else to suggest to you without being able to see what your actual project setup is, sorry. It's possible that something weird with maven is going on, where it thinks that it's exporting the artifact but actually isn't.

Also, "Droid" is a Verizon marketing term. The word you are thinking of is "Android" :eng101:

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Are there any good resources on designing functionality that let users toggle between a light theme and a dark theme? I understand the basics of switching between two themes, but I'm stumped on how to change out the color palettes and icons that are loaded for each theme. Right now my app uses a Theme.Holo.Light-based theme, and so the ActionBar icons and Navigation Drawer use icons and colors themes that account for the predominantly off-white appearance. However, when I set the app theme's parent to Theme.Holo, the ActionBar icons are hard to see and the Navigation Drawer is still white (because of the @color I set it to).

Do themes support something like refs.xml does, in that you can specify different drawables or layouts for a particular value (i.e. for sw600dp devices, @layout/activity_layout in Activity.java instead uses @layout/activity_layout_two_columns)? If not, what can I do so that @color/nav_drawer_bgcolor or @drawable/ac_icon returns one color or icon for one theme, and a different color or icon for another?

zeekner
Jul 14, 2007

Karthe posted:

Are there any good resources on designing functionality that let users toggle between a light theme and a dark theme? I understand the basics of switching between two themes, but I'm stumped on how to change out the color palettes and icons that are loaded for each theme. Right now my app uses a Theme.Holo.Light-based theme, and so the ActionBar icons and Navigation Drawer use icons and colors themes that account for the predominantly off-white appearance. However, when I set the app theme's parent to Theme.Holo, the ActionBar icons are hard to see and the Navigation Drawer is still white (because of the @color I set it to).

Do themes support something like refs.xml does, in that you can specify different drawables or layouts for a particular value (i.e. for sw600dp devices, @layout/activity_layout in Activity.java instead uses @layout/activity_layout_two_columns)? If not, what can I do so that @color/nav_drawer_bgcolor or @drawable/ac_icon returns one color or icon for one theme, and a different color or icon for another?

Are you specifying attribute values?

Example:
Make an attrs.xml in your values folder, then add something like this:
code:
    <attr name="primaryBackground" format="color|reference"/>
    <attr name="listBackground" format="color|reference"/>
    <attr name="footerBackground" format="color|reference"/>
Then, in each theme's <style>, you can specify colors like this:
code:
	//by value
        <item name="primaryBackground">#000000</item>
        <item name="listBackground">#3E4147</item>
	//or by reference
        <item name="footerBackground">@color/footer_light</item>
Then reference those attributes in xml via:
code:
    android:background="?footerBackground"
Grabbing those values at runtime is a little more annoying, I use something like this:
code:
    public static int getThemeColor(Context context, int colorAttr, int fallbackColor){
        TypedValue val = new TypedValue();
        if(context.getTheme().resolveAttribute(colorAttr, val, true)){
            return val.data;
        }
        return fallbackColor;
    };
Be sure to read and fully understand the resolveAttribute function, how you use it will vary based on the type of attribute you are resolving.

Kenishi
Nov 18, 2010

Volmarias posted:

That's because they're probably not. If you use baksmali or something similar on the apk, you'll probably find them missing.

As to why, the answer is usually Because Eclipse. I'm not sure what else to suggest to you without being able to see what your actual project setup is, sorry. It's possible that something weird with maven is going on, where it thinks that it's exporting the artifact but actually isn't.

Also, "Droid" is a Verizon marketing term. The word you are thinking of is "Android" :eng101:
Decided to check my maven POM after your suggestion. The Java project's POM had the source/target java set to 1.7 so I changed it to 1.6 and suddenly it started working again. Thanks!

TheReverend
Jun 21, 2005

So I needed to work on an Android thing again yesterday. No big deal fire up eclipse, etc. Oh look some android component needs updating, updates, breaks other things, update those, endless cycle.....broken eclipse.

So I redownload the latest eclipse and ADT thing, get that going. Projects are starting to build. The only problem is that graphical editor for the layouts isn't working. It'll display the layout but won't let me add UI elements to it in a drag and drop manner.

So my questions are

1)Am I just being a whiny baby for wanting a visual studio style UI thing? Should it even matter and just "XML or go home"?


2)I know the non-eclipse IDE is "beta" but Google will often leave the beta designation on things that work really reliably (like Maps and Earth for the longest time). So.... are you guys using eclipse still or am I an old fogey and need to get with the times?


I spend like 5% of my time doing Android things so sometimes I get left out in the dust.

Tunga
May 7, 2004

Grimey Drawer
If you want Android Studio without the beta tag, just use IntelliJ. It has a much better UI editor than Eclipse, for a start. Though I still mostly end up writing the XML myself it can be useful to figure out why something isn't displaying like I expected, or which particular component I need to edit.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
Definitely try Android Studio, it's way better than eclipse in my experience. Now that it's in beta they promise not to make majorly breaking changes like they did in the past. It updates all the time (like, weekly) but it's good because they're fixing bugs and iterating on it quickly.

Infomaniac
Jul 3, 2007
Support Cartographers Without Borders
I tried out Android studio in the really early preview stage and ended up switching back to Eclipse. Then tried AS about 2 months ago. I don't use Eclipse anymore once I got used to gradle and got my git situation worked out and integrated. I'm never going back, though I will probably purchase intelli j in the future.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Android Studio is still very much a beta, but it's better than Eclipse at this point.

wargames
Mar 16, 2008

official yospos cat censor
So I'm trying to run this thing but I'm completely lost, I don't know where to run the script or what to put on line 37.


http://java.dzone.com/articles/android-email-extraction-eml
https://gist.github.com/rbramley/65261127dfb857b03bb6

kitten smoothie
Dec 29, 2001

It seems weird that they're hardcoding an address for the "from" field (which is what's assigned in row 37) when I would assume the "fromList" would have the appropriate info to put there.

wargames
Mar 16, 2008

official yospos cat censor

kitten smoothie posted:

It seems weird that they're hardcoding an address for the "from" field (which is what's assigned in row 37) when I would assume the "fromList" would have the appropriate info to put there.

The thing I want all of the email from the inbox not just the ones from certain people.

StraightFace
Feb 9, 2014

Volmarias posted:

Android Studio is still very much a beta, but it's better than Eclipse at this point.


I've been wanting to give this a try for awhile now, going to check it out tonight.

Maleh-Vor
Oct 26, 2003

Artificial difficulty.
I'm a designer and I'm making animations for an app. Think of something like this: https://dribbble.com/shots/1623679-Open-Close when you press a button (while still having it be a button). Unfortunately, I can't seem to find any resources explaining how to implement something like that.

I can export it as a gif, png sequence, h264 .mov or .mp4 with transparency, or try to give my programmer instructions on how to recreate animations in code, but I think having to do so with every animation would end up being an inefficient use of his time. We're using Android Studio.

Anyone have any experience with or could point me in the right direction?

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

You probably want something like this I guess:

http://developer.android.com/guide/topics/graphics/drawable-animation.html

You can save your anims as a set of frames and define them in xml, and then have the code start the animation based on things like touch events.

Your issue is that (from what I can see anyway) there aren't any callbacks for when an animation finishes, so your coder will have to come up with a way of handling the switch to a reverse animation. You could set a timer based on the animation's total duration, or do something in the opposite touch event, or something. AnimationDrawable seems a little lacking to be honest, you can even jump to a specific frame from what I can see, so depending on your needs you might need to expand on it a bit

Maleh-Vor
Oct 26, 2003

Artificial difficulty.
I was afraid that would be it. Oh well, 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

Well just to be clear, the actual 'recreating animations' side involves you saving the frames to a folder or something, ordering them with a suffix (I'd imagine that's taken care of by every frame exporting program out there), and then an XML file needs to be generated for each group of frames, so that's something that can be automated to a large extent. And any extra code needed to get around the limitations of the animation API itself would be something you'd reuse where it's needed. So there might be some extra coding involved, but it doesn't need to mirror the work you're producing, you know?

There might also be a few helpful libraries that already implement advanced animation functionality, someone else might be able to recommend some. And it's worth pointing out that Android will be seeing a major UI makeover soon with Android L, which uses something called Material Design which is visually based heavily on movement and transitions and stuff. There might be more robust animation APIs coming in that

Space Kablooey
May 6, 2009


I'm starting up with Android development with a team another guy and I really can't find anything on versioning the android virtual device. I could tell what options to pick when creating the AVD, but that seems prone to disaster in the long run.

I managed to find my system's avd folder, but I still have no idea on how to version it. It doesn't seem like I can change that folder easily.

Tunga
May 7, 2004

Grimey Drawer
When you say "versioning", do you mean saving and loading the current device state? You can use snapshots to do this. Details on this SO.

Space Kablooey
May 6, 2009


I mean in the sense of "sharing the exact same AVD between a team and propagate changes of its configuration, if any, automatically". Like you do with code + git.

I thought about sticking a copy of the avd folder in the git repository, but that doesn't take care of any changes it might have throughout the project. Of course, I don't know if changes to the avd should happen anyway.

kitten smoothie
Dec 29, 2001

My team just set up various emulator run configurations in the project in IntelliJ and named them according to how the AVD should be configured. The AVD name you are to use when configuring is the same as the run config name. For instance, "Nexus4-18-x86" for a 4.3 device using the Nexus 4 profile and x86 system image. We support 4.0.3 through 4.4, so we did this scheme run configs from API level 15 thru 19. Then that got committed to git since it's part of the project config in the IDE.

If you join the team, then you just set up your AVDs based on that, name them the same way, and then you generally never end up screwing with them again otherwise. It's sort of on your honor that you set up the AVDs correctly, but it's not like it's really prone to problems since it's something you're not going to be changing going forward. We've got a team of probably eight developers and none of us have had any issues with this process when people come on board.

kitten smoothie fucked around with this message at 16:37 on Aug 11, 2014

Space Kablooey
May 6, 2009


I think that will work, then. Thank you. :)

Chas McGill
Oct 29, 2010

loves Fat Philippe
I've just finished a couple of modules on Java and I'd like to make small program for Android - a todo list or a simple game (thinking like a quiz or something because I've got very little experience with UI stuff). I'm particularly interested using the touchscreen and widgets since almost all the uni work I've done was text based.

Should I use ADT with Eclipse or go straight to Studio? From reading the thread it seems like Studio is already better than Eclipse, but a lot of the tutorials I've seen have been Eclipse based. I basically just want to have an app on my phone that I can add to as my knowledge improves and to help me get a feel for the platform.

Are those the two viable options nowadays?

Chas McGill fucked around with this message at 17:21 on Aug 13, 2014

Tunga
May 7, 2004

Grimey Drawer
If you're already comfortable with Eclipse then it's fine to go with that. Whatever you prefer really, both are fine. ItelliJ / AS do seem to be more popular for professional use (and are certainly my preference) but I've met various people who swear by each of the three.

Chas McGill
Oct 29, 2010

loves Fat Philippe

Tunga posted:

If you're already comfortable with Eclipse then it's fine to go with that. Whatever you prefer really, both are fine. ItelliJ / AS do seem to be more popular for professional use (and are certainly my preference) but I've met various people who swear by each of the three.
The only IDE I've spent much time with is Netbeans so I'm not familiar with Eclipse either. I've installed Android Studio and I'm setting it up with Genymotion now. Seems pretty slick! The tutorial I'm going through is pretty out of date but the meat of the information is still relevant.

Tunga
May 7, 2004

Grimey Drawer

Chas McGill posted:

The only IDE I've spent much time with is Netbeans so I'm not familiar with Eclipse either. I've installed Android Studio and I'm setting it up with Genymotion now. Seems pretty slick! The tutorial I'm going through is pretty out of date but the meat of the information is still relevant.
Like you, I also attended the Terrible School Of Let's Make Them Use Netbeans That'll Be Funny. Sorry about that. You'll get over it, just give it time.

Yeah, I'd go with Android Studio then. The default keybinds are stupid (which is IntelliJ's fault) but other than that there is no particularly compelling reason to favour Eclipse. Google have made it clear that they will continue to support both but it's obvious where their focus lies.

As well as the official ones from Google, I also found Lars Vogel's tutorials useful:
http://www.vogella.com/tutorials/Android/article.html
https://developer.android.com/training/basics/firstapp/index.html

Adbot
ADBOT LOVES YOU

kitten smoothie
Dec 29, 2001

I really wish Google would just buy Genymotion already.

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