[android-developers] Testing AndroidTestCase as well as ActivityInstrumentationTestCase2
So I've built a test suite that automatically grabs all testcases and runs them. The first chunk of tests I wrote were for AndroidTestCase, and just tested simple algorithms and shared functionality (non ui, Activity in-specific). I came along and built a ActivityInstrumentationTestCase2, that happens to test the first activity of the app. When run alone, all my AndroidTestCase tests run just fine, and likewise when running my ActivityInstrumentationTestCase, they run as expected. When I run all tests for the test project, it appears as if testrunner hangs trying to run my activityinstrumentaiton test cases. (APPEARS to be in the call to getActivity() in setUp()). This as you might guess is terribly inconvenient. I was wondering if anyone has encountered it, and if so, any solutions out there? I saw a post here about making sure to .finish() the activity in tearDown(), but as I only have one activity instrumentation test case, the .finish() didnt appear to have any effect on it whatsoever. Because getActivity() is called in setUp(), setting timeouts etc for the test themselves dont really seem to do much of anything. Any advice would be greatly appreciated. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Android, SQLite, massive (5000%+) loss of performance on a certain query, on a certain device
SQL performance often relies on indexing and quantity of data. Generally fields you join on are going to need to be indexed (as they appear to be pk's). Without a where criteria, you're effectively going to end up with a table scan on english words, and compounded by the joins. I dont know details about the devices specifically, but it is possible sqlite isnt optimized for the nexus. If you arent indexing your tables, do so. Weston On Tuesday, March 20, 2012 3:22:57 PM UTC-7, momo wrote: I'm rewriting a simple translation app with a SQLite db. There is an extreme hit to performance between two queries, but only on certain devices. One query lists the english words in a ListView, the other lists the secondary language in a list view. The data is structured differently, and is from a remote server. Both are single SQL statements, run via db.rawQuery. Both use AsyncTask to keep heavy lifting in another thread. On both devices, the english query returns almost instantly (less than 1 second, every time): return db.rawQuery(select _id as id, english as label from english_words order by english collate nocase, null); On one device, the secondary_langauge query returns almost instantly as well. No problem there, ever. This is a Samsung Galaxy SII. On another device (Samsung Nexus S), this query takes around 30 seconds. This query has some joins, as follows: return db.rawQuery(select definitions._id as id, secondary_language as label from english_words join definition_bridge on english_words._id=definition_bridge.word_id join definitions on definitions._id=definition_bridge.definition_id order by secondary_language, null); I ran it in the emulator once, and got the same result as the Nexus S (the 30 second hang). It took a little 1.5 hours to download and parse the returns from the server on the emulator (which takes a few seconds on either device), so I gave up on further debug with the emulator at that point. This is the only difference between the two operations. The listView is the same, the adapter is the same, the AsyncTask is the same. The number of rows returned is different - there are about 2000 english words, and a little over 3000 words in the other language. I don't think this explains the vast difference in performance. I took the query out of the AsyncTask to see if I could get some more debug info, and did get an ANR: at android.database.sqlite.SQLiteQuery.native_fill_window(Native Method) at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:73) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:287) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:268) at com.whatever.adapters.WordListAdapter.getCount(WordListAdapter.java:39) I rewrote the adapter's getCount method to return a cached count (determined during instantiation). After, I didn't get an ANR again, but otherwise the performance was not improved and the query still took around 30 seconds. I'm totally at a loss. As mentioned, everything but the queries is identical. And on the Galaxy SII, there is no problem at all - less than a second to populate the ListView, even under abuse (touching the button that launches the request as fast as I could). At this point, I'm wondering if it'd be better to abandon SQLite entirely, and using a Java model to manage data. Assuming I can't get the SQLite version to perform reasonably, what could I expect in terms of performance using Collections (with the number of entries mentioned above), when I need to do a search for example (which I imaging would require iterating over the whole thing on each key event). Any advice? TYIA. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Configuring IDE (Eclipse or IntelliJ) for System Development
I'm looking to develop features, fix bugs in the android os, which is going decently with the make my changes, build, push to device, but am looking for something a bit more usable on a regular basis. I've managed to get both ide's able to show many of the projects, and some of the features like go to definition typically work, but I definitely cant build, debug through the ide's at this time. Is there a project file, or official way of setting up ide's for os development anywhere? I know there are development folders in the source tree, but there would appear to be 0 documentation and adding a new module to intellij with the IML in the development/ide/intellij/moduleDefiniitions/testing.iml Can any one provide any advice to development lifecycle stuff? Right now, I'll make the change, then m module adb shell stop adb remount adb shell sync and then adb shell start or just reboot. is there an easier way? Are there actual ipr's for Intellij development on the os source? I'd like to do things like add new screens in settings, and its becoming very time consuming. Any help would be greatly appreciated! Weston -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Getting access to a UI Context safely from anywhere
Mark, Thanks for the tip. If I understand the source right, the idea is that when those events occur, you just broadcast it... say like {some network error message}... and have my base activity listen for those broadcasts? Then because they are implemented on an activity, I should theoretically be able to do something like Dialog d = new Dialog(this); keeping reference to the current class? If this is the case... 1) Would you have problems with multiple activities responding to the same broadcast? It seems like the activities life cycles are not always predictable. It seems like you can have an activity you just spawned via an intent can over lap the life cycle of the original intent. 2) If #1 is possible, do I need to worry about checking to see whether this is attached before attempting to spawn a dialog? I appreciate the input, and look forward to getting this problem solved Weston On Feb 16, 5:19 am, Mark Murphy mmur...@commonsware.com wrote: A variation on that theme is to use an ordered broadcast, so it can be picked up by a foreground activity (if one exists) or raise a Notification (if not): http://commonsware.com/blog/2010/08/11/activity-notification-ordered-...https://github.com/commonsguy/cw-advandroid/tree/master/Broadcast/Ord... (and, yes, a year-and-a-half later, I am finally getting this topic into one of my books...) On Thu, Feb 16, 2012 at 1:48 AM, Kristopher Micinski krismicin...@gmail.com wrote: It seems like what you should really be doing is using a system notification anyway, you don't want to randomly pop up a dialog box (actually, you can probably pop up a toast in your case, which you can do from the application context..), but a system bar notification probably makes the most sense. kris On Thu, Feb 16, 2012 at 1:28 AM, Weston Weems wwe...@gmail.com wrote: Treking Basically this is what I've done... say I have MyAppActivity which has stuff that automatically registers itself into application... events come in, application gets last accessed and I use that to start dialogs etc. Seemed like there were cases where it was throwing exceptions about null window token even though the activity reference itself wasnt null. Ie, just simply keeping a reference around doesnt guarentee its suitable to spawn dialogs (even if it IS an activity). I also tried to have in my base callback a context we pass through... could be activity or app context and thats fine... and say I want to spawn dialog if context is a subclass of Activity... seems like that works decent... but seems like that has potential to have problems if the activity goes away before the callback returns. I guess I am frustrated... I like in IOS dev I can just create a UIAlert, and show =) I know that there are things in place on purpose (for fluid user experience, but for a lot of the stuff I build, its much lower level... rom hacking and such and I do have a legitimate excuse to be wanting to do things the way I want) Weston On Feb 15, 4:12 pm, TreKing treking...@gmail.com wrote: On Wed, Feb 15, 2012 at 5:49 PM, Weston Weems wwe...@gmail.com wrote: it doesnt even seem there is a decent way to test to see if context is 1) a valid ui context from which I can pop dialogs, show dialog fragments etc Don't use a base Context, use an Activity, which itself is a Context, but one associated with UI (as opposed to, say, a Service). 2) know if the reference to the instance of the activity or whatever actually has ties enough to spawn a dialog etc. That is not very clear. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers
[android-developers] Re: Getting access to a UI Context safely from anywhere
Kristopher, This is a completely custom build of the os for very specific hardware. Our software doesn't really have the concept of notification bar. Thats not to say the facilities dont exist, but a user of our hardware doesn't have access to notifications generally. Believe me in out of box AOSP, I totally agree... user experience needs to be fluid and predictable (nothing popping up in the middle of a process, or navigation through the device)... I just dont have those conveniences here. Users use our app, and if the events are happening, the UI should be interrupted. Weston On Feb 15, 10:48 pm, Kristopher Micinski krismicin...@gmail.com wrote: It seems like what you should really be doing is using a system notification anyway, you don't want to randomly pop up a dialog box (actually, you can probably pop up a toast in your case, which you can do from the application context..), but a system bar notification probably makes the most sense. kris On Thu, Feb 16, 2012 at 1:28 AM, Weston Weems wwe...@gmail.com wrote: Treking Basically this is what I've done... say I have MyAppActivity which has stuff that automatically registers itself into application... events come in, application gets last accessed and I use that to start dialogs etc. Seemed like there were cases where it was throwing exceptions about null window token even though the activity reference itself wasnt null. Ie, just simply keeping a reference around doesnt guarentee its suitable to spawn dialogs (even if it IS an activity). I also tried to have in my base callback a context we pass through... could be activity or app context and thats fine... and say I want to spawn dialog if context is a subclass of Activity... seems like that works decent... but seems like that has potential to have problems if the activity goes away before the callback returns. I guess I am frustrated... I like in IOS dev I can just create a UIAlert, and show =) I know that there are things in place on purpose (for fluid user experience, but for a lot of the stuff I build, its much lower level... rom hacking and such and I do have a legitimate excuse to be wanting to do things the way I want) Weston On Feb 15, 4:12 pm, TreKing treking...@gmail.com wrote: On Wed, Feb 15, 2012 at 5:49 PM, Weston Weems wwe...@gmail.com wrote: it doesnt even seem there is a decent way to test to see if context is 1) a valid ui context from which I can pop dialogs, show dialog fragments etc Don't use a base Context, use an Activity, which itself is a Context, but one associated with UI (as opposed to, say, a Service). 2) know if the reference to the instance of the activity or whatever actually has ties enough to spawn a dialog etc. That is not very clear. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Getting access to a UI Context safely from anywhere
Ok, I've encountered several cases where I'd like to instantiate classes that exist as a child of my application subclass, events fire say like a communications error, and we'd like to be able to popup a sort of general communication error anywhere in my app. Another example is say where applicable have a progress dialog for network transport items etc... I'd *LIKE* to be able to just get a reference to the context, in before start, popup dialog, after finish hide dialog. The way I have things setup, we have a base callback for network transport that has started, finished, error etc. Currently we create an anonymous subclass and fire off the request. This works great, but requires us to write implementation handling each and every sort of error etc. (I'd like to have it handled in base class). My callback does have a context constructor parameter, but every context doesnt appear to be a UI Context (from which i can pop a dialog etc), nor does it guarantee that when we try to go to pop it up, we dont get a window token error. For a while I was trying to have each activity onresume set a CurrentUIContext in application, but this seems to be somewhat problematic because it can potentially lead to leaking an activity, and because if not maintained properly, context may be set, but trying to pop a dialog with it ends up wit the window token error. I dont want to try and pop anything from background if my app isnt visible or anything, but it doesnt even seem there is a decent way to test to see if context is 1) a valid ui context from which I can pop dialogs, show dialog fragments etc 2) know if the reference to the instance of the activity or whatever actually has ties enough to spawn a dialog etc. I can see a very small excuse for this strange functionality, people trying to do malicious stuff, or causing unexpected ui behaviour, but other than some very specific cases, my network communications will always be the result of a button click. Any advice here would be greatly appreciated! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Getting access to a UI Context safely from anywhere
Treking Basically this is what I've done... say I have MyAppActivity which has stuff that automatically registers itself into application... events come in, application gets last accessed and I use that to start dialogs etc. Seemed like there were cases where it was throwing exceptions about null window token even though the activity reference itself wasnt null. Ie, just simply keeping a reference around doesnt guarentee its suitable to spawn dialogs (even if it IS an activity). I also tried to have in my base callback a context we pass through... could be activity or app context and thats fine... and say I want to spawn dialog if context is a subclass of Activity... seems like that works decent... but seems like that has potential to have problems if the activity goes away before the callback returns. I guess I am frustrated... I like in IOS dev I can just create a UIAlert, and show =) I know that there are things in place on purpose (for fluid user experience, but for a lot of the stuff I build, its much lower level... rom hacking and such and I do have a legitimate excuse to be wanting to do things the way I want) Weston On Feb 15, 4:12 pm, TreKing treking...@gmail.com wrote: On Wed, Feb 15, 2012 at 5:49 PM, Weston Weems wwe...@gmail.com wrote: it doesnt even seem there is a decent way to test to see if context is 1) a valid ui context from which I can pop dialogs, show dialog fragments etc Don't use a base Context, use an Activity, which itself is a Context, but one associated with UI (as opposed to, say, a Service). 2) know if the reference to the instance of the activity or whatever actually has ties enough to spawn a dialog etc. That is not very clear. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Ideas about how I can start activity without flag activity new task
Ok, First of all, I'll start out by saying I've done research and understand why android prevents people from being able to do such things, but its really preventing me from being able to build this library as I'd like to. Likewise I'd appreciate people who feel the overwhelming urge to quickly respond with: ...you are ruining user experience... or ...your not supposed to do that... or ...everyone will uninstall your app... to kindly keep that advice to themselves. I believe I have a perfectly legitimate case for what I want to do, and the goal is by no means to provide a negative user experience. 1) The goal. I'd like users to be able to simply include a reference to my library and initialize it in onCreate of an application( that part is done, and functions exactly like I'd like it to), consumers of my library will call a number of commands... one of which intentionally pops up some blocking ui of sorts requiring user input. It does not need to popup if the app is in the background or anything It's always gonna be the direct result of a call from the app (eg,not popping up from a service on top of other apps etc). 2) What I've managed to make work I have my app mostly working by having the user call someclass.performLogic(this) where this is an activity. I pass the activity through to the method that fires off logic, and if necessary will use that activity to start a new intent with flag_activity_new_task, and tell activity to .finish(). This is the effect I'd like, however I'd really like to be able to not have to have the consumers of my service to include this in the call. 3) 2 Ideas I had previously were - try and figure out if i could from application context, get a list of activities, and kill the top one (in which case I'd expect starting the new activity with new task, and then killing the previous, I'd effectively achieve what I am now. - try and figure out a way to avoid that all together, and figure out a clever way to get around the requirement for new_task. I've dinked around with launch intent flags, but nothing really seemed to fix the ability for the user to hit back and get the previous pane.( because they were fired off in the root of a new activity heirarchy, and likewise, back would just return you to the previous heirarchy.). Currently the stuff that launches, is in an activity, but there is nothing that says it couldnt be a dialog (seems like theres some potential to force a user to enter information in at least that app, without blocking entire system, or providing negative user experience. I'm just looking for some pointers at this point... I'd really like to go out of my way to get something that least to the most pleasant integration with other developers. if All they had to do was call performLogic(actual relative parameters), and that was it, that would be beautiful. I appreciate any pointers or advice in advance. Weston -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Styling Honeycomb EditText's when inputType is specified
Ok, I've just noticed some oddities with honeycomb ui... and am sure its something I am missing... and hoping someone here has the answer. You know how in holo theme, the edittexts look diff depending on the inputType? Eg, if inputType=number, theres the bottom border, but no top etc. I am re-theming the edittext control, as the holo.dark edittext theme makes it very difficult to realize you are looking at a set of input fields. I am following this tut: http://www.androidworks.com/changing-the-android-edittext-ui-widget And honestly everything generally works pretty well (I dont use 9-patches, but rather shapedrawables). In any place I have inputStyle specified, the edittext doesnt take the style. I assume that honeycomb / theming system supports it as the holo dark theme absolutely styles the inputs differently... but I havent been able to figure it out. I've looked at honeycomb styles.xml and themes.xml, as well as the corresponding statelistdrawables, but have been unable to make it happen, and I'd prefer not to have to find every edittext and specify padding/background etc. Appreciate any pointers! Regards, Weston Weems -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Drag and Drop fires off listeners on different tabpages of the same tab control (z-index filtering?)
How are we supposed to ensure that drag targets in hidden views, or views that exist at a zindex further back than the current views dont get fired? Problem: I build a data grid with draggable grid headers (for column reordering)... and it works fantastic everywhere that I've tried until I've flipped to another tab with another grid and then back. I went ahead and hobbled some stuff together so that the clipdescription has a label of grid_+getId(), to try and filter out items being dropped from other grids onto this one... and it seems to work as my logging in my DragEvent.ACTION_DRAG_EXITED event for only the grid headers on that particular grid. (pseudo code in ACTION_DRAG_STARTED - if(event.getClipDescription().getLabel().toString().equals(whatever) do stuff and return true, otherwise return false) According to the documentation, this should in theory prevent further events from firing relative to this drag event and this listener. The curious thing though, is that the logging of the entire operation looks like this... Started dragging column: FirstName Started dragging column: LastName Started dragging column: Age //bad description, as those are the columns that are responding, not necessarily columns that are being dragged. Dragged out of: Description Reporting dropResult: false //description is a column that exists in another grid in another tabview Dragging stopped column: FirstName Dragging stopped column: LastName Dragging stopped column: Age //finally the ended event Additional note... this seems to only be a problem with the datagrid on the very first tab view, not the other 2 pages in this particular case. So my questions are... 1) first of all is there a better way to segregate drop targets to ensure content that is technically the write type, isnt dropped places it simply doesnt make sense? In this case, I dont want to test that the content type is correct, but rather the target group or parent control id are the same. 2) Am I correct in the assumption that 3 draggable items, I should have 3 simultaneous event chains firing off, and ultimately context is whats key? (eg, button2 is being dragged, button 1 starts and responds to being dragged over... and likewise behind the scenes we should see drag event for button2 saying started, and then a dragevent for button1 firing off ACTION_DRAG_ENTERED? 3) I thought I understood the drag and drop as a single datagrid worked beautifully with dragging columns around, however as soon as there are other items that probably happen to match the same x/y though different z indexes, the functionality breaks. I can try and build a proof of concept to display this erroneous behavior, but wanted to filter out the possibility that I am making a dumb little mistake, before taking time for the POC. Regards, Weston Weems -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to achieve this 3d effect... advice would be appreciated.
I want to what amounts to basically whats in the gallery app, when you see the stacks of images, and you scroll all the way to the end, and the stick of thumbs kinda do a 3d rotate a bit, and ease back. I know android.graphics.camera can achieve some of that, but dont quite get how to handle what ammounts to z-index stuff. Is this something that will require a surface view? I tried to find the source but wasnt able to make very good progress on that front. Seems like camera branch has some of ti, but dont really see the image stacks being manipulated or understand enough about whats going on there Any help/advice would be greatly appreciated! Weston -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] ACRA crash reports library - upgrade required !
Thanks for keeping on top of things Kevin! On Tue, Apr 26, 2011 at 4:17 PM, Kevin Gaudin kevin.gau...@gmail.com wrote: Hi all, I just published a hot bugfix release of ACRA as users reported that reports were not posted anymore since monday. This is due to a change in the way GoogleDocs handles Forms posting, now requiring the usage of https. All applications using ACRA should be upgraded to ACRA 3.1.2 as they can't send their reports anymore. Sorry for the inconvenience. Kevin -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to achieve this 3d effect
Ok, so i am looking to build something that emulates the 3d effect in the gallery with the stack of thumnails, and how when you scroll all the way to the side, the stack of thumbs change perspective a bit, an you can see more/less of the images deeper in the stack. It would seem like I could probably just apply a transform with android.graphics.camera, and then somehow apply the objects one right on top of the next. SOmething like that. I attempted to actually just look it up in gallery, but i couldn't seem to find any code that was remotely relevant. Even just pointers is just fine... the effect I am going for is to either be able to use camera to apply some transforms on a stack of views, or I suppose learn how to draw a view in 3d space ( i think there was a way to draw a bitmap from a view, and likewise draw the bitmap in 3d space). Any info would be great, seeing as it would seem there isnt a WHOLE lot of documentation on the subjects (if I am wrong, I'd be excited to find these online resources). Weston -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Swapping fragments
I've recently put together an app that makes heavy use fragments in the master-details view scenario where you'd select the first list item in the fragment and then details fragment would update accordingly. But Iv'e got another need to actually swap out fragments (for the appearance of how say a tab view would look (clicking on diff things, would produce diff fragments all together, not just the same fragment with slightly different values. What Iv'e tried so far... Check for fragment thats already created with tag... if one exists, replace a dummy framelayout with that, otherwise, create it and replace. On very simple fragments that literally had no id's anywhere etc.. .the fragments worked perfectly as expected... however on slightly more complex fragments, it always seems to complain about the existence of the id's or that the fragment has already been added (after the fragment was shown the first time). Also played with different combinations of removing the fragment if it existed... non of which seemed to be an end all solution. Tried making the parent layout a linearview and just hide/show (which may infact better emulate the effect I was going for anyway), but because its still calling inflate(), it still has duplicate id problems. So this leads me to a couple questions 1) Does a fragment manage knowing anything about an existing fragment have anything to do with being able to see the fragment? It would seem that regardless of adding/removing/hiding/showing, the fragment was always still there. 2) when I add or replace, should I be creating a new instance of that fragment, or could I theoretically have instances... (and does the add process just register it with the fragment manager? 3) Am I going about this completely wrong? I still like that the separation is there, and that the fragments are decoupled and reusable, but doesnt seem like the reuse is actually there.. I cant replace an instance of a fragment with another instance if the other instance. I have done some research and saw the references to the problem with inflating views into parent context or root, and likewise always do my inflation with R.layout.whatever,null,false. Thanks for any help! Weston -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Equivalent to dialog display iniitiated from a service
I know this question has been asked and been shunned for quite some time. Like everyone else, I believe my idea to be the next big thing and likewise I cant explain exactly what I am trying to do, except that I think its acceptable use in my case. The idea is that the service will be chugging along... should something occur with credentials or a number of other things, the idea is that its important and needs users attention more or less right away. After reviewing all the other existing chat discussions on the topic, I can say that I understand why people generally dislike the idea, and why just poppin a notification is the suggestion. Obviously displaying a straight dialog doesn't work, and I guess its understandable so lets move on to popping a activity. I've had it spawning my activity with extras on the intent and that works quite well, but I'd like to be able to hit a button there and have it dump completely back to what user was doing prior to my calling of the user info dialog. What I'm actually noticing is that because the activities can be in use and different states, and the whole FLAG_ACTIVITY_NEW_TASK still appears to try and reuse activities from my app if they are suitable. eg, if i open front end and navigate around, then hit home, then some event occurs, it will navigate to the correct activity in my app... but when I attempt to dismiss with finish(), it returns the my apps main activity. If I force kill it just prior to event occuring, it works 100% like expected. Do I need to specify other flags to spawn an activity with literally no history (like a static method call) or should I be ok there? Is there anyway I can just build a dialog, ask for a couple bits of user info, continue upon its business if user hits ok (or cancel for that matter)? I really believe that android sdk is probably right that there are very very very few cases in which this should be done in the first place... but notifications in this case wont do. Please help! Weston -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Equivalent to dialog display iniitiated from a service
I assume when you say tie/bind here you aren't just referring to spawn activity via intent On Nov 11, 2010 11:03 AM, Streets Of Boston flyingdutc...@gmail.com wrote: Tie/bind your service to a visible activity (let's call it WaitActivity). If it is really important that user reacts immediately while your service chugs along and needs more info, the user'd better be looking at the phone and looking at the WaitActivity. E.g. you could show an activity (WaitActivity) that says 'busy with doing the stuff you asked for please wait.' :-). Then when the service needs credentials or other important information, it can communicate back to the WaitActivity to which it is bound that it needs some info. Your WaitActivity gets the info from the user and sends it back to the service. If your user is no longer looking at your WaitActivity, then he or she is no longer urgently interested in the result or actions of the service. If the user restarts the WaitActivity at some point in time, rebind it with your running service so that the user can get updates/ info-requests from your service again. But as long as your user is not looking at your WaitActivity, you should not interrupt your user. Instead, show a notification that opens WaitActivity which then get the necessary info from your service. On Nov 11, 9:32 am, Weston Weems wwe...@gmail.com wrote: I know this question has been asked and been shunned for quite some time. Like everyone else, I believe my idea to be the next big thing and likewise I cant explain exactly what I am trying to do, except that I think its acceptable use in my case. The idea is that the service will be chugging along... should something occur with credentials or a number of other things, the idea is that its important and needs users attention more or less right away. After reviewing all the other existing chat discussions on the topic, I can say that I understand why people generally dislike the idea, and why just poppin a notification is the suggestion. Obviously displaying a straight dialog doesn't work, and I guess its understandable so lets move on to popping a activity. I've had it spawning my activity with extras on the intent and that works quite well, but I'd like to be able to hit a button there and have it dump completely back to what user was doing prior to my calling of the user info dialog. What I'm actually noticing is that because the activities can be in use and different states, and the whole FLAG_ACTIVITY_NEW_TASK still appears to try and reuse activities from my app if they are suitable. eg, if i open front end and navigate around, then hit home, then some event occurs, it will navigate to the correct activity in my app... but when I attempt to dismiss with finish(), it returns the my apps main activity. If I force kill it just prior to event occuring, it works 100% like expected. Do I need to specify other flags to spawn an activity with literally no history (like a static method call) or should I be ok there? Is there anyway I can just build a dialog, ask for a couple bits of user info, continue upon its business if user hits ok (or cancel for that matter)? I really believe that android sdk is probably right that there are very very very few cases in which this should be done in the first place... but notifications in this case wont do. Please help! Weston -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] 2d drawing with shapes and drawables.
I've done a *TON* of searching and havent been able to come up with a concrete conclusion to this question... I'd effectively like to use the drawables to create a vector image composed of shapedrawables etc. Then use that where drawables are typically consumed... (img src and backgrounds etc). Just have a few questions I hope I can get some verification on... 1) It would appear shapepath isnt supported in xml... is this infact correct? 2) Any simple examples of say a logo drawn out with the paths and shapes? 3) Assuming something doesnt exist and there is currently a need, would anyone be interested in free utilities that would take vector art work, and convert what it can to android drawable files? I am very interested in taking advantage of it, but documentation is scarce. If anyone has done anything remotely complex (more than one shape) per drawable resource, I'd be very interested in seeing it. Not opposed to using code, but can I then refer to say a custom drawable child, from another xml file and have it just work? Appreciate all your time. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Windows Phone and XNA. Nightmare is real. What we do with that ?
Meh. I think its important to keep your finger on the pulse of trends... but the fact is no matter how. Good. Frramework is they may and try apple shenanigans... which makes the scare null andvoid On Mar 17, 2010 6:48 AM, Piotr piotr.zag...@gmail.com wrote: M$ has show already done great XNA gaming framework with VS Express NET 4 for Win Phone 7, ready to download: http://developer.windowsphone.com/windows-phone-7-series/ I bet, most developers will choose WinPhone to create games, if they can just create their games for Zune, X360, PC and WinPhone at once, and because C#/XNA programming is much simplier and takes less time than dealing with Canvas optimization, NDK or OpenGL calls and other stuff, that most developers just do not know how, or do not want to do. I say it again, hoping that some Google Worker is watching :D: Android NEEDS something like XNA. Not for you, professional game makers, but for all community of developers, who want to start with game creation. Creating games is not only a coding, but mostly an art. Good tools allow to focus on art. Lack of tools = poor games, because developers with great ideas will waste their energy on creating tools, not an art. On 11 Mar, 22:25, Mario Zechner badlogicga...@gmail.com wrote: Extremely well written post Bob, thanks a lot for that. I can totally agree to your statements and can confirm that the bottleneck in games is not the Dalvik VM and therefor Java for almost all parts of agame. What kills performance at the moment is way down in the chain at the hardware level. Fill-rate limits are the biggest issue wegame developers have to face at the moment. Everything else does not contribute much, implementing your wholegamein C does not solve that problem. And i speak from personal experience in this case :) On a side note: ExDeus was not developed with the NDK. Thegameis actually a port of an IPhone version so it was developed with the IPhone tools for the most part. Those feature a native debugger. The Android version is probably only different in setting up the gl surface and processing input. On 11 Mrz., 17:01, Bob Kerns r...@acm.org wrote: This comment is perhaps a bit off your main topic, and I don't mean it to derail your efforts or to criticize. But I have a bit of a problem with your statement Java is just too slow..., taken as a general statement. Perhaps you have benchmark data showing specific performance problems, and found it so; I'm not disputing that. However, the performance landscape is a lot more complex than this would suggest, if taken beyond your context. In particular, there are at least 4 performance areas to consider here: 1) Java performance -- which is actually generally quite good in the desktop/server world; I've not done any Android benchmarking. 2) JNI performance -- there's added cost per switch to native code; sometimes it's better to do more work in Java to avoid this overhead, or to batch up work and do more per JNI call. 3) OpenGL library/driver performance. This is both the stuff that's done in software in preparing for the GPU pipeline, and how effectively it makes use of the hardware, and failures to use capabilities that exist in the hardware. 4) The GPU hardware itself Judging from the reports I see here (and not personal experience on this platform as yet), a lot of the performance problems we see are further down this chain. Better graphics hardware and better drivers push the bottlenecks up the chain; faster main processors and Java VM improvements push them down. But where you encounter the bottleneck will always depend on just what the application is doing. Textures are a big part of that, as is managing levels of detail so you don't waste time rendering detail that isn't really noticeable. There are a lot of ways to use OpenGL poorly. And there are a lot of ways to use it well, but push the limits in the search for image quality. Pushing things down in to C++ is just going to harm developers, if it's not actually where the bottleneck is. As Mario says, you have to choose carefully. Do you move your physics engine into C++ -- or just the matrix multiplications? Or perhaps just significant components, like collision detection and the timestep integrations? If you push stuff down to C++, how do you allow for customization, without incurring the JNI callback overhead? Part of what I'm getting at is that because apps are different, the optimal tradeoff will differ. I'm not sure that Google providing a framework would be the way to go. Obviously, each developer implementing their own isn't a good thing either. I think shared community efforts, or commercial libraries make a lot more sense (though there could be an official library as one of these options). This is especially true of physics engines. But there is such wide variation in what demands an application makes of 3D rendering
Re: [android-developers] Re: Want to start building 3d games, pointers?
This is exactly the sort of discussion I was hoping to have. I didnt actually expect to find allt he tools working for me out of the box, but rather hoped to help piece together bits that anyone could use to help expedite it. I appreciate your time... and if i come up with some tools that help out, you guys will be the first to find out about it. On Mon, Mar 15, 2010 at 1:04 PM, Robert Green rbgrn@gmail.com wrote: Ronnyek, There are a few methods of picking a 3D object from a 2D coordinate. The ones I know of are (in order of popularity): 1) gluUnProject to get a ray, then use a collision detection algorithm to check against your object bounds 2) Use the color/depth buffer -- This involves a special little bit of work. -- When a touch comes in, on the next draw, you render the pickable objects without textures, lights, etc, each with a unique color. Keep your Z-Buffer on and you will have colors that represent the objects which are ordered front to back. You then check the framebuffer to see which color is at the touch point and you will then know your object. Erase and do your normal rendering after. 3) You can implement something like gluUnProject yourself if you create your modelview matrix look-at in a separate matrix. It's not as hard as it sounds. You can create your vector starting with 0,0,1 then translating based on the touch x,y and field of view, then finally multiply it by that matrix and you've got it. I'd rather just use unproject, though. As far as loading models and 3D data... The fact of the matter is that there are so many different file formats, each with its own tradeoffs. If you want static geometry, you can just write an OBJ loader. It's not very hard and I actually posted code to my first one: http://www.rbgrn.net/content/313-light-racer-3d-days-1-2-learning-opengl-es Animations... If you want animations, things get harder. You have to pick a tool to use to make your animations, then you have to figure out if that tool exports a format that you can find or write importing code for. Good engines write their own importer/exporters for their own formats. Why no universal format? Different formats allow for different features. Since each game specializes in some way, it's hard to make it universal. It gets worse - you can't just import into opengl. Opengl is great, but it deals with primitives. If you want to animate, you need to understand some 3D geometry foundation because you have to know how your animations really work, down to the vertex. I ended up using Blender/MD2 as my tool and animation format. You'll see all of this in our upcoming game next month. MD2 is nice because it's very easy on the CPU if you write an interpolator in C and use fixed point math for it. The loader took a few days to figure out but there are docs online that go over the file format in detail. The problem with it is that since it doesn't use bones, you can't combine top/bottom animations and you can't just reskin. You also can't mount weapons easily (though we did it with some nasty hacks). As for levels.. I haven't found an optimal solution yet. We used blender and manually partitioned out space into visible areas, separated by visibility portals. I wrote a visibility portal occlusion algorithm so that we only draw the areas that are currently visible. We create a separate collision mesh which I load into an octree (native code is a must for this stuff) and perform collision tests on (also always in native code). The advantage to this is that it uses off-the-shelf tools and formats. The downside is that since we don't use a proper level editor, we don't get nice things like built in entities, surface types, etc. We had to hack it all in. How long did all of this take us to learn and do? I started learning OpenGL ES last september and really started this game in November. That puts us around 5 months on this title and we're still a good month away from being done with it. Too long for my tastes but it does take a lot of time to learn how to do all of this stuff so I'm glad I invested the time to learn. On Mar 15, 1:00 pm, Mario Zechner badlogicga...@gmail.com wrote: Hi, let me start by answering your questions: 1) What you refer to is usually called picking and involves a bit of math. Your initial goal is to get a ray (defined by a starting point and a unit length direction) from your touch coordinates. This can be done via GLU.gluUnProject (http://developer.android.com/reference/ android/opengl/GLU.html#gluUnProject(float,%20float,%20float, %20float[],%20int,%20float[],%20int,%20int[],%20int,%20float[], %20int)). With this ray you can now check wheter an object in your world has been hit. Usually your objects will have something called a bounding volume like a sphere or an axis aligned bounding box (nice keywords for google). All you then have to implement is a ray/bounding volume