Android multitasking problem - java

I have an android application which main view consists of a tab-bar with three tabs in it.
When developing and running the application on the device through adb I get the following behavior:
When clicking the phone button "Home screen" and relaunching the application it seems as the application continues where I was before pressing the button (remembers selected tab etc...) (apparently its still running in the background).
However when I export and sign the application (using Eclipse) it suddenly always seem to start a new instance of the application when returning from home screen.
Why does it behave so different in those cases? And what do I need to do in my application in order to always have the "running in background" behavior.

If you always want your application to have "running in background behavior", then set android:alwaysRetainTaskState="true" in your main activity manifest. This prevents Android from periodically resetting your application back to the root activity.
android:alwaysRetainTaskState

It sounds as though your application is being destroyed between the point that you go to the home screen and start the app back up again. This can be due to not having enough memory available on the device. If you have a lot of background apps running on your device this may be the reason it is happening.
I would recommend debugging and checking out which path is being hit, that is, whether or not your app is going through just the onResume lifecycle method, or if it is also going through the onCreate lifecycle method.

Related

GWT load fragments after application start

I am creating an app in GWT, and I just recently implemented code splitting there. I reduced the application size from 1.1MB to 570kB which is nice, so the startup time of the application is now faster (we are using special server where 500kB really matters... not important for my question though ...). After the application starts (in other words user can see login page, can login and use basic parts of the app), I would like to download the rest of the fragments.
I know the fragment will be downloaded when the code in the fragment is needed. But one of the fragments is about 300kB. So when I click in the menu of my app on an item, that causes this fragment to be downloaded, there is a very noticeable delay (1 - 2s), before the user gets a response.
Now I understand that this will most likely happen only once and then the fragment will be cached for like a year, so it will load faster next time. But for example when I try it again on another device, I will have to download fragment for the first time again.
I just need to be sure, that when user launches my app on a phone/tablet using wifi, then disconnects from the wifi or gets out of its range, he will still be able to launch the code in the fragments, even if he didn't launch the things that cause downloading them while he was still connected to the server.
Now he would have to open 3 menu items, to download all the fragments which is annoying.
So in short:
I want my initial download to stay 570kB, and download the rest of the app as soon as possible on the background (if possible).
EDIT:
I found http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html#sequence where you can setup initial loading sequence, so I guess it is what I am looking for. Not sure though if they are loaded asynchronously, because the login screen appears after the fragments are downloaded.
You can cause all fragments to be downloaded after the login panel is rendered. Simply call some method inside the rest of the code - it does not need to do something visible.
Also, if you plan to load all code this way, you only need to split one fragment - your entry point with the login panel. Each split point (a) slightly increases the overall size of the application, and (b) increases, sometimes significantly, the size of the leftover fragment which still needs to be loaded for the first fragment to show up. Thus, there is no point in having more than the initial fragment and the rest of the app, given your requirements.

Testing of Android Application without resetting its state using Appium and Selenium WebDriver

I wish to test my android application without resetting its state. I noticed that different popups appear everytime I run the application so I wish to log all the various popups.
My definition of "run" here is tapping the back button on my phone and tapping my application icon again.
However, I am unable to simulate this physical tapping of the phone on my Appium test. I can exit my first test but I am unable to reopen my application again. (Simulation of tapping on the application icon with my finger)
Things I have tried:
1. Setting noReset to true in capabilities setting
2. Using uiautomator to find my application. However, uiautomator doesn't seem to be able to detect any icons in the app menu page. It just shows many layers of frame layouts.
3. closeApp() and launchApp() resets the application and this defeats the purpose of my test. My application somehow behaves differently with each run so I hope to run my test in a single session (i.e. closing and opening the application while it is still in the same state)
Is there anyway I can simulate the physical tapping of the icon in the form of code? I know we can set the coordinates but I don't want to hard code my test to run only on a specific instance of the phone. It will not run if other applications are uninstalled and my application icon shifts to another position.
This worked for me:
"appPackage": "com.company.app",
"appActivity": "com.company.app.activities.HomeActivity",
"skipDeviceInitialization": true,
"skipServerInstallation": true,
"noReset": true
This won't reinstall the .apk, appium server and it won't delete the appdata. You can just start the app like you've left it before starting the test.
I found this browsing the same issues on GitHub:
https://github.com/appium/appium/issues/4955
https://github.com/appium/appium/issues/3783
If I am not getting you wrong here, you can try using a combination of following using AndroidDriver :
driver.navigate().back(); // from app home screen to mobile home screen
driver.startActivity(String appPackage, String appActivity); // or possibly cast ((AndroidDriver)driver)
You can start the app by giving The package name and start activity name instead of apk file in desired caps , this way ur app won't be reset every time u launch app
Den use presskey4 for tapping in back button , den u can call launch app function to launch the app without reset

My Activity is closed, when i press back button

When a user press the back button or home button, the activity is still alive. BUT in a few minutes or may be hours sometimes when they close the app and open it again the app starts from the first activity instead of resuming.
This problem is faced by lots of users. Some user have launcher installed in their phone and when they uninstall it the problem is solved. Users who don't have launcher installed also have the same problem. The app should work properly despite of the fact that external launcher is present or not. Also for testing I installed the launcher (Nova launcher) and my activity never closed. I don't know why.
Anyone have any idea about that?
Thanks!
Can you please check that by any chance you have set the Don't keep activities option to true, in Developers options.
Keeping that true will cause the similar kind of issue.

BlackBerry app whose icon disappears from App Switcher but still is running?

How can I make a BlackBerry app have an icon but when a user does something within the app the app will disappear from the app switcher but be running in the background? I'm thinking of a timer app that will do that. Then when the timer is up it will reappear.
You have to have your application run in two contexts, one a UiApplication context with an icon, one with an Application context without an icon. The Applicatin may be autostarting, or may be started by your UiApplication. This can be done by specifying an alternate entry point into your application.
You have to be very careful with your coding though. Applications that don't exit and are badly written can have a huge impact on performance, battery life and data usage.

change my home in android if my application is running!

I want to change my home in android device my requirements are like following
whenever I run my application my that time on pressing home key should be disabled
so that time on pressing home key should do nothing.
but if I close that application my home should be the previous one that is launcher
So it is possible on basis of running application my home get set
I use to change in manifest.xml file and disabling the package com.android.launcher but it won't satisfy me.
Long story short... no, you cannot do this.
There are some things you can do as workarounds that would themselves be hacky at best and basically not deliver the functionality you want. Like making your application be home replacement (launcher) itself then applying the desired functionality but even in that scenario it wouldn't do what you described you want done because you wouldn't really ever get back to the previous user defined home app (launcher) and there would be system dialogs the user would need to traverse to set your app as the home replacement (launcher).
Just so it is super clear though, you cannot override the functionality of the home button without the user confirming the action.

Categories

Resources