Bug? B4A app is black on switching back to Active App

Discussion in 'Bugs & wishlist' started by Simon Smith, May 10, 2015.

  1. Simon Smith

    Simon Smith Active Member Licensed User

    Hi, this may or may not be a bug.

    I have a simple application. I have a Galaxy S5. I run it normally. If I go to any other app, no matter what it is, whenever I return to my app - pitch black screen.

    Simon
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is most probably not a bug in B4A.

    Please try to reproduce it in a small project and upload the project.
     
  3. Simon Smith

    Simon Smith Active Member Licensed User

    Done, wonder why FirstTime makes a difference, wouldn't you think it would be in the same state you left it? Pitch black.
    Must be compiled as release obviously and ran as release.
     

    Attached Files:

  4. NJDude

    NJDude Expert Licensed User

    The problem is that you are loading the layout "If FirstTime = True", that's wrong, by doing that, it means you are loading the layout only when the app runs for the very first time.
     
    lemonisdead and thedesolatesoul like this.
  5. Simon Smith

    Simon Smith Active Member Licensed User

    That doesn't make sense and goes against every application programming convention I have ever had to do with from CPC to Pocket PC, to Applicaiton Programming where a task exists, to Android where a task should "load the layout only when the app runs for the very first time".

    I have never heard of (say in Windows alt-tab) you having to reload the whole application. It is in memory, all screens are drawn just not in focus. I don't believe this is the answer, it may be the cause but cannot be logic.

    If someone is in the middle of typing into a layout, of course you don't want to load it again and wipe out what they've done just because they went to settings. Erel?
     
  6. NJDude

    NJDude Expert Licensed User

    Well, that's the answer, that's how Android works.

    Read THIS thread.
     
  7. Simon Smith

    Simon Smith Active Member Licensed User

    Wow thats crazy. What a waste of resources. Thanks.
     
  8. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Bear in mind, the idea is that the user is only running one app (which is in focus), there is no point to keep all the other apps active and use up valuable resources.
    The way Android works is that you must save everything on activity Pauses and restore them on resume.
    Its not a waste of resources, it ensures that low resource devices can function when apps are coded properly.
     
    hibrid0, NJDude and RandomCoder like this.
  9. Simon Smith

    Simon Smith Active Member Licensed User

    Well that is the complete opposite of http://blog.radioactiveyak.com/2010/05/when-to-include-exit-button-in-android.html
    Why have multi-tasking? In Pocket PC World which Erel will be familiar with there was garbage collection. A well programmed App in my opinion should close when they leave but Android don't want that. Neither does iOS. Nor is it conventional in Visual Basic, .NET, C++, any Windows Application, even linux applications (despite Android being linux) or any other language. If thats the case, then is there a way of knowing when the user has left? The WindowState reports wrongly when you have multiple views. I would prefer to either close it and clean it than keep it open. However, there are no events (that I've seen) where I can put an ExitApplication plus it is practice that is not promoted by this very site.
     
  10. thedesolatesoul

    thedesolatesoul Expert Licensed User

    I dont quite understand your argument but...
    In Android, we expect every activity to clean up in its wake. Once it goes into the background, there is no guarantee it will come back alive.
    For services, they can be user closable (notifications) or just die when they finish.
    The user has left, once the activity is paused. (but may be on another activity).
     
    NJDude likes this.
  11. Simon Smith

    Simon Smith Active Member Licensed User

    Yes services I consider different.

    Simply, what is the purpose of multitasking when you should not end an application but you should practically redo everything when they come back? Windows must be wrong. Linux must be wrong. Mac must be wrong. iOS must be wrong. Yes a programmer should stop events and any timer or any action, but doesn't the user want to go back to the same state they left it. Since when did the conventions of programming disappear.
     
  12. Simon Smith

    Simon Smith Active Member Licensed User

    The OS should be in control of prioritising memory and resources to the foremost application and core OS. Anyway - I'll just reload it every time, problem solved.
     
  13. thedesolatesoul

    thedesolatesoul Expert Licensed User

    From the end-users point of view it makes no difference. He wouldnt notice anything. But as a programmer you would, but that doesnt matter.

    If in your opinion everything has to be classed as right or wrong, then you probably will really struggle with multiplatform development. Android has been out there and is successful for a large number of years. It didnt have to be right or wrong, it was a different architecture, which has been proven to be reasonable successful so far.

    They didnt. They just imposed more restrictions on the way you code.

    Exactly.

    I think overall you have made the distinction between the 'app process' and the 'activity'. You are not reloading the layout in the activity every time, but only when the activity is killed/exited. 'FirstTime' will be false only when the activity was killed (either due to Activity.Finish or the OS reclaiming resources) but the 'app process' was not.
     
    NJDude, lemonisdead and RandomCoder like this.
  14. Erel

    Erel Administrator Staff Member Licensed User

  15. Simon Smith

    Simon Smith Active Member Licensed User

    After 25 years as a APPLICATION (not tiny phone) developer, I trust consistency and logic. That's what brings us here.
    ahh, it's called logic!
     
  16. thedesolatesoul

    thedesolatesoul Expert Licensed User

    So are you arguing that android architecture is illogical?
     
    NJDude likes this.
  17. Simon Smith

    Simon Smith Active Member Licensed User

    All I wanted to do was swap tasks. ALT-TAB. Simple. Convention and logic since the day GUIs started. A programmer must program correctly, what I think is poor is that most people these days use wizards and controls. I used to program with pixels, why do people think everything should come on a silver platter?

    I do agree. It is very obvious what is happening. Apps if they weren't all 'non-native' pretend real coded apps wouldn't take up that much resources. Phone's with 16GB RAM - I think somewhere along the way people have forgotten to program concisely and natively and relied on wizards, custom controls and the detriment to that is that you sadly can't control the outcome - because you didn't write the source from ground up. I guess this points out a big distinction in programming with say the old reduced Win32 Windows Mobile SDK which was built for efficiency to the clunky phones that if we all would have predicted 10 years ago would be the size of a finger.

    Pocket PC's died but the concept was built with an API for raw efficiency. I guess the VB6 gurus out there can relate to the horror stories in REAL BUSINESS CORPORATE application development, for pharmaceutical companies, or banks, etc, where not knowing 100% of the insides of your code is DETRIMENTAL and makes the difference between a real programmer and what they teach these days. That's why so many people rejected .NET. There is not one thing it can do that C++ or even VB6 can't.

    Security and restrictions I get, but why have a brick full of 16GB RAM, app companies promoting massive slow memory HTML5 games or FAKE apps taking 3 times the memory, and then say - but its still a mobile so we should allow you to get back to that, but kindof.

    Android did not follow the convention and broke the rule of logic with this one. Ah well. Every programming language is as good as the other apart from what they put on top that you can't control. I will not make a company application with one dependency without writing my own controls and it works - but with the monopoly Apple and Android have created for mobiles - developers just say - ah well, HTML5 - poorer quality apps, less innovation. HTML5 can't do 1/1000th of native code. PS. I wrote a patent that uses an online system that Microsoft Apple and Google are all waiting for the results for in the Full Federal Court of Australia and every patent country is watching my invention - setting law in Australia - manner of manufacturer. If my patent is upheld then Google and Apple actually don't run the risks of having their Australian patents invalidated. My patent beat the government in the Federal Court, and she appealed and she still will probably lose.

    Check this out patent followers: http://blog.patentology.com.au/2015/05/software-patents-back-under-appeals.html

    The world awaits!
     
  18. Simon Smith

    Simon Smith Active Member Licensed User

    No not arguing, just confirming the comment made before
    Before iOS and Android Pocket PC, Win32, Even Linux and almost any GUI I can imagine relied on good code. The problem is the programmer making cheap copied code, if we went back to "LOGIC" we would have micro APIs like Pocket PC built to conform with the C++, VB, GUI rules. I'm not saying anything - I just think that if they are looking for a consistent answer to
    they stuffed up.
     
  19. Simon Smith

    Simon Smith Active Member Licensed User

    Java is probably the closest they will get which ironically in web development is asynchronous - which kind of asks the question are we multitasking or not. PS - No negativity here-I am just saying that Apple probably put a spanner in the works because ultimately it will die however as far as Application programming goes, I will never see C++/raw VB (which ironically is capable of doing what C++ can do if you know what you're doing) or raw Java leaving. The mobile SDK answer is not HTML5. I have an Octocore S5 and tried to play a simple game with my 32gb ram S5 and it struggled. :) This phone is more powerful than the fastest PC I had 5 years ago.
     
  20. thedesolatesoul

    thedesolatesoul Expert Licensed User

    I am not disagreeing with what you said above, but every company has to make these strategic and design decisions. Sometimes they turn out to be better, sometimes worse than before.
    My only point is that this particular aspect of the OS you are not liking, is actually pretty good. Its funny that you would complain about this, while also talking about how resources should be utilized effectively? I dont think any OS does that as well as Android (pardon my ignorance about iOS but thats a closed system). If you have no paging file, what happens on Windows if you run out of memory? What happens on Android? Sure using a JVM kind of thing on a mobile is inefficient but we are not talking about that.
    Hmm...I wouldnt say that. Mobile device specs sound great but in reality the bottlenecks are about other things like thermal envelope and bandwidth. Besides, you have a Samsung, what do you expect ;)
     
    NJDude likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice