Sunday, May 17, 2015

browser - Function of back button after opening URL from (Twitter) application


When opening a URL in the official Android Twitter app it opens the native browser, showing the page for that URL. If I tap the back button in the browser (Galaxy S, 2.3.3, should it matter), one of two things happens:



  1. The browser goes back in its history opening the previous page/url it had opened.

  2. Android switches back to the Twitter app, back to the tweet with the URL I opened.


It eludes me what triggers either situation, it's seemingly random. I prefer option 2 when I'm reading my Twitter feed, can someone explain the logic behind this and perhaps even tell me how to make sure I trigger option 2 while reading my Twitter feed?




Answer



Your problem touches a feature of Android that sets it apart from other mobile OSes and is a very powerful one (see below):


That's all about intents, activities and the back stack that contains your path of visited activities in order for each app. Basically an activity is a single GUI fullscreen window you see, for example the main activity when you launch an app. If you navigate away from that, lets say to the settings view, the now inactive main view is put on the back stack and so forth.


However: This whole behaviour has many switches that are solely customizable by the app developers.


See this link for the basic information on those things:


http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html


Regarding your specific problem:


It might be a difference if the browser was (1) already open, (2) had an active Twitter tab running (that got reactivated) and so forth. Try some of these combinations (use 'force stop' in the app settings to end browser instances and have an/no open Twitter tab in the browser active beforehand), and you will find:





  • If you have opened the max of four windows in your browser, then opening an URL from the Twitter app will "re-use" one of them. If you hit back in that browser window it will first go all the way back up the history, one history item at a time. Once the history is empty, hitting the back button once more will send you back to the Twitter app.




  • If you had not opened the max of four windows in your browser, then opening an URL from the Twitter app will create a new browser window. If you hit back in that browser window the history for that window will already be empty, and you will directly go back to the Twitter app.




Some more information:


The unique system are Android's intents. New views are launched by an intent that, for example says 'open this file in a file view' or 'select a picture in a gallery viewer' or 'authenticate a my app with Facebook' and so forth. Without saying which other app should handle it. You see this when you get a choice menu asking you to select a specific browser (native/Chrome/Dolphin/Opera) or one of many file explorers you might have installed.


This one of the very powerful Android features. Apple's iOS is very different to that, apps can't interact with others so closely and Facebook integration had to be done in iOS6 the hard way for that reason (directly integrated into iOS).


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...