Texture loading: Everything at once OR un-/loading the needed assets? - java

We've been developing quite a huge game for android on the basis of AndEngine. So we have a lot of assets to load, especially textures.
At the moment everything (sound, textures etc) for every screen (menu, shop, etc etc) is loaded when the app starts (while showing a progress bar). This way the user only has to wait once about 16 seconds at the start of the game. We think that this is a pretty pleasant solution from the users perspective but might it be bad in terms of battery usage / memory usage or any other reasons?
What arguments speak for a solution where we unload all the screen specific assets of the active screen and load the assets needed for the next screen?

In my opinion, the best way to go is "lazy loading", i.e., load resources only when you need them. That way you are not making the user wait for resources he will not use. So what I do is, when the app starts, I load the menu's resources during an opening splash screen, and when the user go to the play scene (for example), I unload the menu resources (hence clearing memory), and load the relevant resources for the game sequence, during yet another, different loading splash screen. That way, in total, the user waits the minimum time, and the memory is loaded with needed resources only.
Besides, from a user's point of view, I think it can be annoying to wait for a whole app to load, when all you want is to show your friend the score you reached.

I've done an app that uses a lot of textures (both HD and LOW depending of the device, etc) and I use the "lazy loading" approach. This app is meant for the kids so there's a lot of animations and illustrations. My first menu is so complex that I have to load 19 textures (2044x2044) so I need to show a splash with a progress bar. From that menu you can choose to play some mini-games or watch some videos. If the kid choose to play a game I show another progress bar while the game textures are loading (another 5/6 2044x2044 textures depending on the mini game). If the kid comes back do the main menu I unload the game textures. If the kid wants to watch some movies, well in this case "it gets worse" because now I have to switch to "Android Activities" instead of AndEngine, so I unload the Main menu textures otherwise OutOfMemory would be thrown. If the kid comes back to the main menu all the textures will be loaded again. I think this is the best approach for you, "lazy loading", and you'll find out that this approach will save you a lot of memory.

Related

How to show a black screen when an Android app goes in background

For security reasons I want to show a black (in dark mode) and white full screen (in light mode) when the app goes in the background.
The standard approach should probably be to use FLAG_SECURE but this will not cover the entire screen (e.g., if the status bar is of a different color you will see it) and the background color is not customizable.
After I also compared the solution created by common banks and finance apps like N26, Revolut, Unstoppable Domain, etc. I came to the conclusion that they are using something different. They are able to render a full black/white screen without content.
Which approach are these companies using?
I also tried to show a black view on top (listening to the onPause on the main activity) and removing it onResume and although the black view is added the screen shown in the recent apps is still the previous one.
I tried react-native and vanilla android apps.

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.

Prevent Android Webview to show blank screen while navigating

I created an Android WebView app. Right now, I am facing 1-2 seconds of blank screen when navigate between pages. I cache all the resource (js, css, html), but it still show me the blank screen for few hundred milliseconds. It is very quick, but the blank screen still noticeable.
Is there any way to skip or hold the transition screen? Like prevent the page to refresh until all DOM and resources are fully loaded.
Make it into a single-page app!
Control the transitions yourself with AJAX (or an framework that abstracts it).
This way you can load the site content and only update it when it is done loading (or add your own loader animation)

Is capturing screen image and displaying it on an application every second effective?

I'm new to programming but I really wish to improve, right now learning Java. Basically there is this game, online strategy it's pretty basic with most of the images are static and very few of them change. I wish to change how I view the game from my end and add some functionality to it as well.
For example the website displays an orange rectangle, I wish to display a red rectangle by drawing over it. Or drawing a button when, if clicked, re-directs me to another part of the game. Originally I am using Selenium Chrome WebDriver to navigate the website but it seems you can't paint or display your own images over it. So I was wondering if I should use Selenium headless in the background performing tasks while I just make a Java Application. Make the WebDriver capture the image every second and display it on the Java Application every second, and than edit that image to my liking? Would this be effective way to do it or is there better options?
It is not clear what you are actually trying to achieve here. And whether your approach is likely to be "effective" depends what you are trying to achieve!
However, I can see some issues:
I don't know if it is technically possible to get the Selenium WebDriver to do that ...
Capturing images at a high rate could be problematic from a performance perspective.
Once you have captured the images:
Modifying the images by hand would be tedious and labour intensive. (And probably not what you want to do.)
Modifying static images programatically would be possible, but fiddly to implement and incredibly fragile. The slightest change to the game's screen rendering could result in your "tweaks" writing to the wrong place on the image.
Making changes to the dynamic part of images would be next to impossible ... except in the destructive sense.
You can't affect game play by this approach. Nothing you do to the images will impact on the browser and hence on the server. You can't add functionality this way.
In short, this is a poor idea, and unlikely to achieve anything worthwhile.
Can I think of any good options? No I can't.
The best I can think of would be to:
reverse engineer the HTML / Javascript uploaded to your browser,
figure out what you want to change in that content, and
place an HTTP proxy between your web browser and the server that injects the relevant changes into the content.
However:
It will be a lot of tricky and tedious work to implement.
It will be fragile; i.e. changes to the game / game server are liable to break your "hacks".
It could be a violation of the game owner's copyright and/or the license that grants you the right to use the game. This could result in your game accounts being cancelled, along with the accounts of anyone else who uses your "hacks".
My advice? Just play the game!

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.

Categories

Resources