Those are indeed dirty hacks. Changing the User Agent is really a nasty solution and should never be done. When loading twitter.com in a webview, you'd better try the piece of code given there :
https://stackoverflow.com/a/6625418/162178
For lazy clickers I'll give it here :
webView.getSettings().setDomStorageEnabled(true);
All credits goes to gregm, who gave this one :)
Happy coding !
Edit: Just a little update to justify this choice, User Agent are meant to give the visited site the info about who's the client.
If one day Twitter makes special changes dedicated to Android, they will definitely use the User Agent to achieve that.
If you tell them your an iPhone or whatever you might never get redirected or more simply never get the css intended specially for Android.
And in a more political matter, if everyone changes it's User Agent, site statistics will be wrong and they might never see there are a lot of Androids coming to their website. ^^
(To maybe consider engaging the proper updates to their website). And this whole thing is not only for Twitter web clients. So be nice.
Benjamin's answers here seems quite good to (using Java's Reflection to make it backwards compatible if I'm correct)
So again don't change the User Agent it is very bad for your app and the web health. And should simply be banned from any code out there. Thanks :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…