Currently I am doing an internship in the mobile team at LinkedIn. It has been a fantastic experience. I spent most of my term working with iOS, and I recently moved to Android. My first task on Android was to work with webviews. For those who don't know, webviews are basically views with web pages that can be loaded within the app. They are similar to the browser, except that a browser is loaded as a separate application.
My task was to bring up a webview within the app using a DialogFragment. I was expecting this to be as simple as creating a webview instance and loading up the url (as this was the case for iOS). However this simple task turned out to be tedious and cumbersome in Android.
I first had to right code to attach the cookies to the webview. I used CookieSyncManager to achieve this. On iOS this is transparent to the developer. Once this was completed the webview was being loaded. However, I wasn't done just yet.
The next task was to fix the keyboard on the webview. There was a text field which on tapping didn't bring up the keyboard. This is apparently a bug in android, and after tons of searching around I was able to bring up the keyboard however the keyboard input was not being entered into the text field. I consulted my mentor however we weren't able to find a solution.
Another really weird thing about webviews is that it doesn't allow you to make a HTTP POST request with additional headers. You can add additional headers with GET request though. I have no idea why Android would impose such a restriction.
So how did I fix this? Well the first thing I did to fix the keyboard problem was to get rid of the DialogFragment and load the webview within an Activity. This was not a preferred option because we were building a static library, and using an Activity within the library adds an additional requirement to the client where they have to specify the activity in their Manifest file.
It was a good experience to learn about the pain points of Android webview in comparison to iOS. Atleast with webviews, iOS seems to do a much better job.
I first had to right code to attach the cookies to the webview. I used CookieSyncManager to achieve this. On iOS this is transparent to the developer. Once this was completed the webview was being loaded. However, I wasn't done just yet.
The next task was to fix the keyboard on the webview. There was a text field which on tapping didn't bring up the keyboard. This is apparently a bug in android, and after tons of searching around I was able to bring up the keyboard however the keyboard input was not being entered into the text field. I consulted my mentor however we weren't able to find a solution.
Another really weird thing about webviews is that it doesn't allow you to make a HTTP POST request with additional headers. You can add additional headers with GET request though. I have no idea why Android would impose such a restriction.
So how did I fix this? Well the first thing I did to fix the keyboard problem was to get rid of the DialogFragment and load the webview within an Activity. This was not a preferred option because we were building a static library, and using an Activity within the library adds an additional requirement to the client where they have to specify the activity in their Manifest file.
It was a good experience to learn about the pain points of Android webview in comparison to iOS. Atleast with webviews, iOS seems to do a much better job.