|
Ulysses S. Grant posted:Nothing wrong with just calling rawQuery on a SQLiteDatabase object until you start to have more complex queries. The CommonsWare library is ace for asynchronous SQLite queries, but you may not actually need it.
|
# ? Feb 26, 2013 06:15 |
|
|
# ? May 13, 2024 07:20 |
|
Karthe posted:Oh yeah, making the queries and processing the returned results isn't the issue. I was just looking for a simple way to do all of the queries in a separate thread so I don't freeze the app's UI thread. I'll try and do everything in the main thread for now - with luck I'll be able to get away with it. Use the commonsware library. It's only slightly overkill, not massive overkill like providers.
|
# ? Feb 26, 2013 08:35 |
|
Someone finally explained CursorLoader to me in a way I could understand. I promptly realized that I never "got" them because I'd been trying to cram a square peg into a round hole. I'm creating a database app and need to be able to query the database with whatever word the user is looking up. My understanding of how CursorLoader works is that you need one for each query you want to make, and that each query is set in stone the moment you set up the loader. I switch between three possible queries based on whatever word is entered in the search box, so I need to be able to cycle through them freely. My end goal is simply to move the querying into a separate thread to keep the UI responsive. Is that possible? Doctor w-rw-rw- posted:Use the commonsware library. It's only slightly overkill, not massive overkill like providers. In addition to all that, while trying to diagnose some skipped frames, I turned on STRICT MODE and was presented with some errors like this telling me about my improper cursor usage: quote:03-01 14:14:49.403: E/StrictMode(18678): Finalizing a Cursor that has not been deactivated or closed. If I set a cursor to close after I finish setting it to a ListView, the app crashes with the following error: quote:03-01 14:33:11.833: E/AndroidRuntime(19099): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteQuery: <query here> I was trying to address this issue with CursorLoaders but obviously that failed so now I'm double stuck. Where the hell do I go from here? I spent most of the day trying to figure these two problems out and now I'm feeling way overwhelmed by all of this
|
# ? Mar 1, 2013 23:38 |
|
Karthe posted:Someone finally explained CursorLoader to me in a way I could understand. I promptly realized that I never "got" them because I'd been trying to cram a square peg into a round hole. Karthe posted:If I set a cursor to close after I finish setting it to a ListView, the app crashes with the following error: It's critical that you remove the cursor from the adapter before you close it.
|
# ? Mar 2, 2013 08:24 |
|
The swapCursor(null) advice is correct to my recollection, but are you sure you're supposed to close it? http://stackoverflow.com/questions/8864813/if-and-when-to-close-the-database-when-using-commonsware-loaderex-sqlitecursorlo?rq=1
|
# ? Mar 2, 2013 10:03 |
|
Sorry, I should have been more specific. I was saying he should only close it if he was managing the cursor himself (no loaders, ect).
|
# ? Mar 4, 2013 05:59 |
|
Salvador Dalvik posted:An easy way to change query arguments with CursorLoaders is to just call restartLoader, and it'll call the onCreateLoader method again where you can return a new CursorLoader with the new query.
|
# ? Mar 4, 2013 06:35 |
|
I'm building a simple app that queries my site, gets the json response, then displays data in a view. I'm having trouble grasping how to pass data to a view, though. I'll be taking several fields from each response, and I assume I need to use a listview. Does anyone have a guide that helped you understand passing data to views?
|
# ? Mar 4, 2013 16:57 |
|
Fluue posted:I'm building a simple app that queries my site, gets the json response, then displays data in a view. I'm having trouble grasping how to pass data to a view, though. I'll be taking several fields from each response, and I assume I need to use a listview. What kind of data are you displaying? Listviews are meant for lists, and you'll want an adapter to use them properly. Is it sufficient to just have a plain old TextView? If so, then it's as simple as calling setText.
|
# ? Mar 4, 2013 23:36 |
|
Volmarias posted:What kind of data are you displaying? Listviews are meant for lists, and you'll want an adapter to use them properly. Is it sufficient to just have a plain old TextView? If so, then it's as simple as calling setText. I'm making an app "clone" of my website http://randompokemongenerator.com I'm assuming ListView is best because I'm looping rows (up to 6 max). I have a JSON response page setup that I'll use to take url GET values in the app based on user selections (same as on the website).
|
# ? Mar 5, 2013 01:12 |
|
Trying to get some numbers together to do my taxes. I love how the payout & sales reports in the Google Play publisher console totally do not agree in any way with the payout and sales reports in the Google Checkout console.
|
# ? Mar 5, 2013 16:30 |
|
How can I solve this issue I'm having with transitioning an app from one-column mode to two-column mode on rotation? When I'm holding my device in portrait mode, my app brings up Fragment B with additional entry information when I tap on a listView item in Fragment A:pre:----- ----- | | | | | A | -> tap -> | B | | | | | ----- ----- pre:--------- | A | B | --------- pre:03-06 11:01:54.953: E/AndroidRuntime(2947): FATAL EXCEPTION: main 03-06 11:01:54.953: E/AndroidRuntime(2947): java.lang.RuntimeException: Unable to start activity ComponentInfo{test.dict/com.test.dict.ActivityStartScreen}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3692) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.ActivityThread.access$700(ActivityThread.java:141) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1240) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.os.Handler.dispatchMessage(Handler.java:99) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.os.Looper.loop(Looper.java:137) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.ActivityThread.main(ActivityThread.java:5041) 03-06 11:01:54.953: E/AndroidRuntime(2947): at java.lang.reflect.Method.invokeNative(Native Method) 03-06 11:01:54.953: E/AndroidRuntime(2947): at java.lang.reflect.Method.invoke(Method.java:511) 03-06 11:01:54.953: E/AndroidRuntime(2947): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 03-06 11:01:54.953: E/AndroidRuntime(2947): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 03-06 11:01:54.953: E/AndroidRuntime(2947): at dalvik.system.NativeStart.main(Native Method) 03-06 11:01:54.953: E/AndroidRuntime(2947): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 03-06 11:01:54.953: E/AndroidRuntime(2947): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.Activity.setContentView(Activity.java:1881) 03-06 11:01:54.953: E/AndroidRuntime(2947): at com.test.dict.ActivityStartScreen.onCreate(ActivityStartScreen.java:21) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.Activity.performCreate(Activity.java:5104) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 03-06 11:01:54.953: E/AndroidRuntime(2947): ... 12 more 03-06 11:01:54.953: E/AndroidRuntime(2947): Caused by: java.lang.IllegalStateException: Fragment com.test.dict.FragmentSearch did not create a view. 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.app.Activity.onCreateView(Activity.java:4740) 03-06 11:01:54.953: E/AndroidRuntime(2947): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680) 03-06 11:01:54.953: E/AndroidRuntime(2947): ... 22 more
|
# ? Mar 6, 2013 22:04 |
|
Karthe posted:Is this something a fragment transaction could solve? I use it right now to bring up Fragment B in one-column mode, but as I write out this post I'm starting to think that I should dynamically load up fragments with FragmentTransactions in lieu of setting up my fragments statically in the activity's layout file... Yeah, pretty much. Load them up in FragmentTransactions. Also, remember that fragment state on the backstack is thrown away completely on configuration changes (such as orientation), though the backstack isn't destroyed. Just the state.
|
# ? Mar 7, 2013 02:35 |
|
Doctor w-rw-rw- posted:Yeah, pretty much. Load them up in FragmentTransactions. Also, remember that fragment state on the backstack is thrown away completely on configuration changes (such as orientation), though the backstack isn't destroyed. Just the state. And everything I've read about fragmentTransaction.add()/replace()/etc... says to attach it to a ViewGroup in the activity's layout XML file. I've been getting along fine with this activity XML file in my test app: XML code:
|
# ? Mar 7, 2013 22:20 |
|
It's been a while so the stuff is fading from memory. I do remember a few things:
|
# ? Mar 8, 2013 03:54 |
|
Doctor w-rw-rw- posted:
quote:
Actually, this should be okay now: http://developer.android.com/about/versions/android-4.2.html#NestedFragments As far as I know nested Fragment support works in the support library as well. It looks like the person who made this StackOverflow post was having a similar issue and solved it: http://stackoverflow.com/questions/7707032/illegalstateexception-when-replacing-a-fragment Glimm fucked around with this message at 03:29 on Mar 9, 2013 |
# ? Mar 9, 2013 03:26 |
|
What's the best way to close a foreground activity and pass info back to the parent activity after rotating the screen? My app displays two columns in landscape mode and one column in portrait mode. When the device is in portrait mode, tapping on a listView item in Activity A starts up Activity B and displays additional information about that entry. I ultimately want to pass Activity B's current entry ID back to Activity A when the device is rotated into landscape mode while Activity B is active. Right now I've got the following set up in Activity B's onStop(): Java code:
|
# ? Mar 12, 2013 14:47 |
|
Karthe posted:What's the best way to close a foreground activity and pass info back to the parent activity after rotating the screen? My app displays two columns in landscape mode and one column in portrait mode. When the device is in portrait mode, tapping on a listView item in Activity A starts up Activity B and displays additional information about that entry. Maybe use one Activity with a landscape orientation containing two Fragment containers and a portrait orientation with only one, and just maintain state within the single Activity?
|
# ? Mar 12, 2013 15:24 |
|
Glimm posted:Maybe use one Activity with a landscape orientation containing two Fragment containers and a portrait orientation with only one, and just maintain state within the single Activity? Here's a video of the strange activity I'm seeing with my current code: https://www.youtube.com/watch?v=yhKeoNMPV-8
|
# ? Mar 12, 2013 15:54 |
|
Karthe posted:I tried using FragmentTransaction's earlier to do the whole two-column-landscape/one-column-portrait but it got real messy, or at least was beyond my ability. Maybe check out the Master Detail View sample that comes with the SDK? Create a new project within Eclipse (target SDK 11+) and select the Master Detail View template and try to match what you're doing with the sample.
|
# ? Mar 12, 2013 16:13 |
|
Karthe posted:What's the best way to close a foreground activity and pass info back to the parent activity after rotating the screen? My app displays two columns in landscape mode and one column in portrait mode. When the device is in portrait mode, tapping on a listView item in Activity A starts up Activity B and displays additional information about that entry. Use startActivityForResult/onActivityResult. stuff your data into an intent. Parcelable is better than Serializable when possible (Serializable uses reflection, and is slow; Parcelable requires you to implement a builder/parceler Protip: rather than calling startActivity or startActivityForResult, I usually make a class method that resembles: static void start(Activity activity, String arg1, SomeObject arg2) - or startForResult to indicate that it returns a result. It's much easier to find where an activity is launched from when all you have to do is find where a function is called from.
|
# ? Mar 12, 2013 16:41 |
|
Doctor w-rw-rw- posted:Use startActivityForResult/onActivityResult. When you rotate to portrait, Activity A only shows the listView. Tapping one of those entries pulls up Activity B with additional information: When I rotate to landscape while Activity B is in the foreground, it displays nothing, probably because I've called finishActivity() in its onCreate intending to dismiss this activity and return to Activity A. Unfortunately Activity B sticks around until I hit the back button: How can I get Activity B to disappear automatically instead of sticking around as in that last picture? I thought finishActivity() would do that, but apparently it does everything BUT dismiss the activity.
|
# ? Mar 12, 2013 22:17 |
|
Don't do activity life cycle stuff in onCreate IMO. I don't really understand what you want to do. You want orientation changes to back out of an activity? If that happened to me I would consider it a bug. What if someone is in a bumpy train ride and the orientation changes? What if you later decide to launch that activity from some other place where it doesn't make sense to close it?
|
# ? Mar 13, 2013 02:00 |
|
Doctor w-rw-rw- posted:Don't do activity life cycle stuff in onCreate IMO. I don't really understand what you want to do. You want orientation changes to back out of an activity? If that happened to me I would consider it a bug. What if someone is in a bumpy train ride and the orientation changes? What if you later decide to launch that activity from some other place where it doesn't make sense to close it?
|
# ? Mar 13, 2013 05:08 |
|
Karthe posted:I'm simply trying to design an app that gracefully switches between a one-column layout and a two-column layout depending on orientation of the device. The reason I'm going for something this fancy is because a two-column layout in portrait mode on a Nexus 7 (the only physical device I have to test on) suffers from columns that are a bit too small to appreciably display listView items. Based on all the trouble I've had thus far, though, I think I'll abandon this for now and just make a two-column layout for sw600dp+ tablets, and use a one-column for everything smaller than that.
|
# ? Mar 14, 2013 00:24 |
|
NoDamage posted:You should almost certainly use fragments for this. I've done the exact same thing for the Nexus 7 (2 columns in landscape, 1 column in portrait), it's not too hard if you're using fragments for each column. Use layout aliases to specify which layout to use depending on the width of your screen. That's the thing, I've been using fragments since the beginning. What I haven't been able to do is figure out how to make those fragments work in a way that gives me that flexible of a layout. I kept having issues loading information into a fragment in portrait single-column mode and then reloading the information in that fragment when it gets reloaded in a landscape layout that contains it. I've given up on that for now and just made the two-column layout the default layout for all tablets, including the Nexus 7.
|
# ? Mar 14, 2013 01:45 |
|
Is there some kind of updated go-to guide to dealing with assets for Android? Things like resolution, etc. Very recently I've somehow become lead developer on an in-progress barely-beta Android app that is targeting -8 and above, all smartphone screen sizes (but bigger/newer phones are priority), horizontal and vertical. And I'm going crazy working with our designer and trying to figure out how to handle resources and screen sizes. I want to be able to tell him "give me x, y and z, designed for these resolutions, proportioned for these sizes" but I don't even know what to ask for when it comes to deliverables, or the best way to manage it on my end. The designs are very graphics heavy, and kind of iOS-like.
|
# ? Mar 15, 2013 03:44 |
|
admiraldennis posted:Is there some kind of updated go-to guide to dealing with assets for Android? Things like resolution, etc. Get to know 9-patch really well. They are a major timesaver, and it's pretty easy to convert existing PNG files to 9patch. Ignore Google's 9patch utility, just use Paint.net or something to resize for one extra pixel border, then save the file with .9.png. Since you are in control of asset creation, you can have the designer target all three major DPI levels (MDPI/HDPI/XDPI). The other DPI levels aren't really worth targeting, MDPI can scale down to LDPI without issue and I don't think the 480dpi level (XXHDPI) will matter for a long time. I haven't even been able to find a XXHDPI phone to see the difference. Honestly, in a pinch you can usually get away with targeting XHDPI and let the scaling handle it, but that can leave noticeable artifacts for XHDPI->HDPI. If you need a quick and dirty iOS to Android port, converting @2x resources is pretty handy. Just make sure to convert stretchable resources (buttons, backgrounds, ect) to 9patch.
|
# ? Mar 15, 2013 08:47 |
|
FYI, someone has the latest release of AQuery set up in Maven Central now and is offering to help keep it current. (Maven is wacky, but we use it at work, so....) Just set it up in my current project - works like a charm! Now to clean up all these loving calls to findViewById
|
# ? Mar 15, 2013 18:35 |
|
Has ActiveAndroid come up before? Can I gush over this library for a bit? https://github.com/pardom/ActiveAndroid ActiveAndroid posted:ActiveAndroid is an active record style ORM (object relational mapper). What does that mean exactly? Well, ActiveAndroid allows you to save and retrieve SQLite database records without ever writing a single SQL statement. Each database record is wrapped neatly into a class with methods like save() and delete(). Examples pulled from the GitHub page: Create some model classes code:
code:
https://github.com/pardom/ActiveAndroid/blob/master/src/com/activeandroid/content/ContentProvider.java Haven't used it much, just set it up today for a new project. But so far, so good. Glimm fucked around with this message at 14:59 on Mar 23, 2013 |
# ? Mar 15, 2013 23:19 |
|
Anyone else looking for a mobile focused dev conference to goto? I didn't win the I/O lottery so I've been looking at a few options. AnDevCon Boston (28-31st May) looks fairly promising, kind of pricey at $1395 a ticket. Droidcon London (24-27th October 2013) seems awesome. Much cheaper (£100 ~ $152 USD). The ticket+flight will actually be cheaper for me if I go this route, and hey - it's in London! I'm not really sure what to expect out of training sessions/classes/talks as I haven't been to either conference or any major dev conference. Anyone checked these out before?
|
# ? Mar 21, 2013 16:17 |
|
Glimm posted:AnDevCon Boston (28-31st May) looks fairly promising, kind of pricey at $1395 a ticket. This AnDevCon looks like it could be pretty good, at least considering Jake Wharton and Mark from Commonsware are on the speakers list. I might have to consider this one.
|
# ? Mar 21, 2013 16:24 |
|
Glimm posted:Has ActiveAndroid come up before? Can I gush over this library for a bit? I bought a copy a few years ago when I started doing Android dev, and it worked pretty well. Had a few minor bugs here and there (which I'm sure they've fixed long since).
|
# ? Mar 23, 2013 07:54 |
|
Murodese posted:I bought a copy a few years ago when I started doing Android dev, and it worked pretty well. Had a few minor bugs here and there (which I'm sure they've fixed long since). Are we talking about the same library? https://github.com/pardom/ActiveAndroid This is released under the Apache license and appears to have only been under development for 4 months or so.
|
# ? Mar 23, 2013 14:58 |
|
Same library, he's obviously made it free. It was originally a paid library (maybe $10?).
|
# ? Mar 23, 2013 15:33 |
|
Hey Android peeps. I'm unclear on this. When I'm working with, say, a Canvas, are there any device-independent pixel density (like iOS does for retina displays) or is everything in actual pixels?
|
# ? Mar 25, 2013 07:47 |
|
I'll probably post in one of the IYG android megathreads about this, but maybe someone here might know better: I'm trying to track down an issue with my phone (droid razr hd maxx, android 4.1.2) and my new car stereo's bluetooth interface. Specifically, there is some weird interaction between the two. When it starts up, it seems to be sending the Play command (or play/pause? I'm actually not sure), causing Android to (eventually) launch the registered application and resume playback. However, a good portion of the time it immediately skips to the next track (which is a problem when listening to a podcast, or just to audible). I can work around it by launching Pandora right before I start the radio, which I use as a meatshield, but sometimes it ignores that (even though it should have then been registered) and launches a different application anyway. Now my question: Is there any way for me to debug what exactly is going on in android.media.AudioManager? I think that is where all of this is handled, so I'm hoping it might hold clues about (a)why this is happening and (b) why it doesn't always happen. I also need to figure out why it didn't behave this way using my previous Bluetooth audio adapter, but I don't even know where to start looking for that. Any ideas?
|
# ? Mar 25, 2013 21:49 |
|
Is there a way to programatically disable the android WebView from loading the mobile version of a website? It seems that the WebView defaults to loading mobile versions, but for my purposes I pretty much need it to load the default version of the website.
|
# ? Apr 1, 2013 20:56 |
|
GenJoe posted:Is there a way to programatically disable the android WebView from loading the mobile version of a website? It seems that the WebView defaults to loading mobile versions, but for my purposes I pretty much need it to load the default version of the website. Maybe try using WebSettings: http://developer.android.com/reference/android/webkit/WebSettings.html#setUserAgentString%28java.lang.String%29 code:
|
# ? Apr 1, 2013 20:59 |
|
|
# ? May 13, 2024 07:20 |
|
Glimm posted:Maybe try using WebSettings: Thanks, that worked pretty well.
|
# ? Apr 2, 2013 00:31 |