I have created an application that has a lot of pages and the user navigates from one to another according to his needs. The application runs smooth when I'm running it from the PC, but as soon as I put the .apk file in the device and make it run independently it behaves erratically.
It opens random pages on Button Click which are supposed to appear after a few frames. My best guess is that incorrect intent passing etc is causing this and that's why I'm tagging this question with Intents.
Can this be happening because I am not firing Intent.FLAG_ACTIVITY_CLEAR_TOP while I'm moving from activity A ->B but only when the user presses the back button B -> A.
Any help here is appreciated !!
PS: Though I don't see the need for any code, please comment in case someone needs to see it.
Related
I am up to write Selenium+Appium test for Android app.
This app has activity with button. Tapping this button will open another activity above first one. So at this moment there will be 2 activities for application (I can see this if in Android Studio I will execute "Layout inspector" for my app, and Studio will ask me in "Select window" dialog which activity to use).
With apium I can work with first activity, but not with second. I can not find any element with any was (by id, by Xpath). Even tap on screen with TouchAction does not work on second activity. I tried dirrerent real devices and Emulators.
When I use driver.currentActivity() command, I will see that driver is using second activity.
But I have really no clue what to do and how fix this.
Hope you solved same problem and can help me.
Thank you.
I'm trying to build an application that would run at the same time as another one, on top of it (hiding only partially the original app), that would display useful information for the user of the main app.
But it seems that 2 activities cannot run at the same time, overlap, etc...
For argument sake, lets say the app would be displaying date & time in a corner of the screen, while playing a specific game.
Anyone got any doc or sample code on how to achieve such a result ?
I'm also interested in how to know which app is currently running in order to decide in my app-on-top to be visible or invisible.
Any help appreciated :)
Thx
Looks like you are in need of Fragments: Fragments
The Android system is designed to be user friendly, and two activities at same time is not, so only one activity is on foreground at once. if you need the other to be running in background make it a Service, if you want to show some data and get back first one use a Dialog, finally if you want both you can either put them in one activity or use Fragments as #Tooroop suggsets.
Its propably too late ... but for others with the same problem:
check out how-to-draw-on-top-of-other-applications
and maybe also this if your app need to be on top on fullscreen apps
what is the best practice regarding the back button currently?
A lot of apps save and restore an entire activity stack when you open them (after they've been onStop and onDestroyed), take Facebook for example, when you open it and your last place was in a photo, then pressing back doesn't close the Facebook app, it takes you back infinitely till the very first thing you did when you opened the app days ago.
This design convention is a little different than what the back button would be expected to do, I think. Where it typically is used to kill the app or stop the main view taking you back to your device's launcher screen.
Facebook was just one example of an app doing this.
Are there developer articles or an authoritative source like Google I/O discussing the utility of this feature (restoring activity stack and having back button traverse through them) vs other functionality (killing the view taking user back out of the app)? If so, please discuss and link them here. I hope this isn't considered too subjective because there is a proper use of the back button as well as an incorrect use
What the Facebook app does actually is the basic default behavior of Android. Those apps don't do anything special regarding that behavior. The Activity stack is saved by default.
One of the more cited blogs regarding it is CommonsWare's BACK means Back. Basically, the functionality of the "BACK" button means it should to take you to the previous page that you just were at. In Android, this is very often the last Activity you just pushed. If the user wants to leave the app, then he or she can press the "HOME" button and that will always push the Activity stack and take the user to the homescreen.
What this means is, the functionality of the BACK button is entirely dependent on the app in question, but the concept is to reverse the action that the user just did. If you are in a game, you go to a sub menu, the BACK button should take you to the top menu. If you are in a browser, the BACK button may take you to the last webpage you were viewing. If you are in a browser and you are in the top page, the user may expect the BACK button to close the app since the last action the user did prior to opening the browser is open the app. If the user starts a download, the BACK button may be to cancel it.
One functionality improvement that Facebook and others like is may consider is to wipe the stack after x number of days since the user may not remember exactly what they did since being interrupted from the last use. The use case for this is very small though.
Overall, this is why people always stress usability testing. You have to figure out what 99% of the people of the app expected when they press the back button.
You can find on the Android Developer site that you should not change the expected behavior of the back button. Let the OS handle the back button.
App does not redefine the expected function of a system icon (such as
the Back button).
That quote is pulled from their Core App Quality page.
You should consider using Up Navigation. You can read more about designing for it here:
Lastly, here is a tutorial on how to implement various types of navigation (lateral, ancestral [up], temporal, descendant).
check here
From my personal experience you can close most, which are using back pressing to go to a previous screen, with a long click on the back button. The best example is the browser app, whether its the native one or a third-party browser
I think that behavior depends on application logic.
By default it is desired to move on previous screen (activity in back stack, or fragment if it was saved to the fragment's back stack).
Actually there is no any silver bullet for this case. Just use "back-pressed implementation" what ever you want. My point is that on back pressed, application must be shown in previous logical state.
Can anyone help with my android app. I am using eclipse and it is a lengthy page app. At page 18 is tells me that it stopped unexpectedly but after you hit the force close button it starts at the same place and it works correctly.
It is a simple quiz app with back and next buttons. This is the only button that wont work on the first try but as I said after you hit force close the app starts up at the same place and the button works just fine. Then you can also go back and forth over that same page without a problem...what gives?
user1009028, we need more information to be able to know for sure what is going on.
Sometimes, for mysterious reasons, the app seems to "crash" and yet still run. There are a number of possibilities here.
If you can post your full code online somewhere, that is great, but even just the logcat will be useful. Since you know how to reproduce the error, get to the page just before the crash, clear your logcat, then go to the next page so it crashes. Then copy and paste everything in your logcat to here in Stack Overflow; that will be the most relevant information related to the crash, which may or may not give enough detail--at least we'll know what to ask for then :)
Regarding your question on "com.csg.SlideNineteen#405761f8", the default toString on objects gives the class name and its address in memory. The numbers at the end are the address of the object in memory... not very useful in most cases.
Some days ago I have published my application in Android Marketplace and a question came into my mind during designing and developing application. This question is about limitation or unlimitation of number of activities.
For example, my application includes 37 activities. Is it so much? I want to know for a game such as "Angry Birds" which has more than 200 levels, it has 200 activities?!!
My next question is, assume that I am designing an application which includes 100 activities. User starts application and gos into last activity (such as reading a book). If user wants to close the application what should he do? 100 times press back key on his devise?!
If I want to put close button(to help user) in options menu, do I have to repeat it for each activity? because as far as I know each activity has its own menu.
If i put close button in last activity and user clicks on it, program will close. What will happen to other 99 activities? are they still exist in stack? or When I close an application, all activities related to that package will delete from stack.
I have read activities page published by Android but I couldn't find my answers.
Sorry if above questions are stupid questions :)
Thank you
In the case of Anry Bairds, I doubt they have 100s of activities, I think they just have one (or possibly a couple) for levels and another for the welcome screen - different levels are probably loaded depending on some parameter that was passed to the activity.
As for how to handle 100s of loaded activities, first of all, it is very likely that the system will recycle the old ones at the bottom of the stack before you get to the 100th activity. If not, then yes, your user will have to click back through a 100 activities.
If you want to change the behaviour of what the back button, you can override onKeyDown().
Or if you want to change the default behaviour of how activities are launched, then take a look at activities launch mode.
Please read Tasks and Back Stack and Activity and Task Design Guidelines
Well, first, regarding angrybirds, I guess it is written nearly entirely in OpenGL ES, so it consists of only a few activities.
And second, if you're really having 200 activities, you should probably think of an activity which can be reused multiple times. e.g. why would you need one activity for every page of a book, if every page should have the same look and functions? Just fire an intent with extra data and it should work. And, to close the app, you can simply press the home button :-)
An application like Angry Birds probably has one activity with an OpenGL ES view, with all of the interfacing done with a RelativeLayout
that being said, you could have an unlimited number of activities, the only concern is how much space your app will take, why any user would want to navigate through such a robust program on their mobile device, and how much RAM you are using and are you managing your activities efficiently