{"comment":{"url":"https://api.github.com/repos/medic/medic-android/comments/14354197","html_url":"https://github.com/medic/medic-android/commit/075a6badfc5087af45fddbf7d096c5b3502b98dc#commitcomment-14354197","id":14354197,"user":{"login":"alxndrsn","id":191496,"avatar_url":"https://avatars.githubusercontent.com/u/191496?v=3","gravatar_id":"","url":"https://api.github.com/users/alxndrsn","html_url":"https://github.com/alxndrsn","followers_url":"https://api.github.com/users/alxndrsn/followers","following_url":"https://api.github.com/users/alxndrsn/following{/other_user}","gists_url":"https://api.github.com/users/alxndrsn/gists{/gist_id}","starred_url":"https://api.github.com/users/alxndrsn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxndrsn/subscriptions","organizations_url":"https://api.github.com/users/alxndrsn/orgs","repos_url":"https://api.github.com/users/alxndrsn/repos","events_url":"https://api.github.com/users/alxndrsn/events{/privacy}","received_events_url":"https://api.github.com/users/alxndrsn/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":"","commit_id":"075a6badfc5087af45fddbf7d096c5b3502b98dc","created_at":"2015-11-12T12:31:00Z","updated_at":"2015-11-12T12:31:00Z","body":"If the call fails, I think `ValueCallback.onReceiveValue()` is called with the `String` value `\"undefined\"`.  In which case, we close the activity.  This is what happens when you press HBB on the login page, for instance.\r\n\r\nI agree decoupling from angular could be nice.  I'm guessing you mean change the code:\r\n```java\r\ncontainer.evaluateJavascript(\r\n\t\t\"angular.element(document.body).scope().handleAndroidBack()\",\r\n\t\tbackButtonHandler);\r\n```\r\nto e.g.\r\n```java\r\ncontainer.evaluateJavascript(\r\n\t\t\"window.medicmobile_handleAndroidBack && \" +\r\n\t\t\t\"window.medicmobile_handleAndroidBack()\",\r\n\t\tbackButtonHandler);\r\n```\r\n...and then define the following in `medic-webapp`'s javascript:\r\n```javascript\r\nwindow.medicmobile_handleAndroidBack = function() {\r\n  return angular.element(document.body).scope().handleAndroidBack();\r\n}\r\n```\r\nIs that correct?"}}