Android Intent consistency
Some time ago, I wrote a thing about Android that mentioned how nice Activities are. I've been trying to write the odd Android app recently (aren't damp miserable evenings great?) and this has prompted me to work out exactly what's going on, and I'm very confused.
The iPhone is simple, though very annoying. If you're in a twitter client, and you click a web link, the twitter client will quit (let's ignore the 4.0 multi-tasking stuff here, because it doesn't really change the underlying metaphor) and the web browser will open. The only way to get back to your twitters is to quit the web browser, run the twitter client again, and then maybe it's remembered where you were. Also, your web browser still has that window open in the background.
Sometimes, to get round this, the twitter client implements its own web view. You click a link, and you'll get an embedded web browser. This time you can go back to the twitter client, and you're not messing with the state of another application. But you can't bookmark the page you're looking at, because you're not really in your web browser. And the twitter client has had to do a lot of programming to get to this point, which I'd rather they spent on twitter-related features.
On Android, the interface revolves around Intents. My twitter client can just start a 'VIEW' intent with the URL of the page I want to look like. The system will interpret this by opening a web browser and putting it over my twitter client, displaying the page I wanted. If I press the hardware 'Back' button, I'll go back to the twitter client. Best of both worlds yay.
But at a system level there really is a web browser application here that I'm starting. It's not just a magical disconnected window. What's going on? Can I construct a meaningful model that tells me what's going on?
Testing on my Hero here has revealed the following behaviour:
Suppose I have my web browser open, looking at foo.com, and I have some browser history. Wow, what a site. Now I tap the Home button, and open my twitter client, to see if anything is up. Someone has twittered something with a link, so I click that link. A web browser window appears, and the link opens, so now I'm looking at bar.com. Let's call this my base state.
Suppose I press 'Back'. I return to my twitter client! Yay. If I then press Home and open my web browser app, I see foo.com. Perfect.
Ok, so instead of that, I don't press Back from the browser to get back to twitter, but instead I press Home, then re-launch my web browser application. Now when it opens, I'm looking at bar.com. If I press Back in this state, I return to the home screen. If I now open the web browser again, I find myself looking at foo.com. But if I press back now, I won't return home, instead I navigate backwards in my browser history.
So opening a link from another application has actually hijacked my current browser tab/window/whatever, and navigated it somewhere else, but with a hook in the history so that when you press 'back' over that note, it closes the browser and returns to what you were doing before. Which should have been twitter, but I'd relaunched the browser from the home screen, so it closed the browser. When I returned to my browser and saw foo.com before, it was because I'd navigated back to it from bar.com, but the interface had hidden that fact from me.
This is confusing.