0

The issue that I am having is, when I open the required website from my app which has got a WebView in it, the website redirects it to mobile-site. I don't want this to happen.

I want to view the website as it seems from a pc/laptop. I can understand the website is prepared like that to redirect, but I want to restrict it doing from my app. So that I can browse the website as in my pc using mobile.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
rodeofest
  • 3
  • 2

2 Answers2

2
webview.getSettings().setUserAgent(1);

Try this. Basically some mobile browsers have this setting which can set to save your default choice. Some don't.

D'yer Mak'er
  • 1,632
  • 5
  • 24
  • 47
  • but m still facing 1 issue with the site , the website uses javascript , so i enabled it using .getSettings().setJavaScriptEnabled(true); but still its not opening . it goes to home page , and the loading symbol continues to display. the website is www.gaana.com/#!/radiostations – rodeofest Apr 18 '13 at 11:27
  • http://stackoverflow.com/q/5110916/2021499 maybe this link will help. check it out. – D'yer Mak'er Apr 18 '13 at 11:38
  • i tried the solution present over their , but didnt worked out for me :( to be precise , i'm testing this in emulator , not in my mobile . – rodeofest Apr 18 '13 at 11:48
  • i would recommend you to test it on a physical device. as some plugins for browsers are pre-installed on the emulator browsers. as you would be creating a new chrome client. it becomes pretty obvious that you do have chrome installed on that emulator. isnt it? – D'yer Mak'er Apr 18 '13 at 11:52
  • no , i dont have chrome installed , rather than chrome client , i used setWebViewClient(new WebViewClient()); i'll better try in mobile , since i cannot do it at present , will update with the results asap .thank u so much for ur help :) – rodeofest Apr 18 '13 at 12:03
  • hie , sorry i know m late , but m getting this error , from mobile , probably this is due to flash player not installed , i tried various way's to install flash player , but all in vain.. the error log is – rodeofest Apr 18 '13 at 19:24
  • Uncaught TypeError:Object # has no method 'getLength' at http://a1.gaanacdn.com/min/?b=media/js&f=jquery/jquery.min-v1.js,ui_pack-v5_r2.js,jquery/global-v2_r3.js,clickCapture.js,,playerQueue-v6_r3.js,managePlaylist-v6_r4.js,gridView-v6_r4.js,jquery.bt.js,thumbView-v6_r5.js,jquery.text-overflow.js,gaana-fb-music.js,easyXDM/easyXDM.debug.js,scrollbar/jquery.mCustomScrollbar.js&version=7.27:1844 V/webview(3833):singleCursorHandlerTouchEvent -getEditableSupport FASLE E/Web Console(3833): Flash is not installed or is too old at http://connect.facebook.net/en_US/all/vb.js:52 – rodeofest Apr 18 '13 at 19:27
  • http://stackoverflow.com/questions/15170807/installing-flash-on-an-android-emulator this question will help you install the flash player on the emulator or a device too. – D'yer Mak'er Apr 19 '13 at 05:12
  • i tried installing all the possible ways and from different sources , whenever i try installing adobe flash , the error come as application not installed. this is carried out in my android mobile having version 2.3.6 – rodeofest Apr 19 '13 at 08:09
  • refer to the link I have given carefully. flash can be easily installed if you are following the steps mentioned there. just connect the device to your system. open the adb. enter command > adb devices if you see your device listed then type in > adb install location_you_have_stored_your_apk/flash.apk This will definitely install flash on your device.Secondly I recommend that if this doesnt solve your question then post a separate question about this as it doesnt have any connection to your question here. – D'yer Mak'er Apr 19 '13 at 08:49
  • Ok , i will, thank you so much , u are really helpful . thanks – rodeofest Apr 19 '13 at 08:54
0

You could change the user agent string of the WebView, since the website decides whether it serves you the full or mobile site based on that. My user agent string is just an example (mine, actually), so you can change that to any non-mobile browser.

myWebView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.0; rv:20.0) Gecko/20100101 Firefox/20.0");
Michael Zajac
  • 55,144
  • 7
  • 113
  • 138
  • thank you , even ur answer worked fine for me , though i didn't modified other than variable name , but , 1 issue is thr as i stated above , even after enabling the javascript , i cannot enter into the website . – rodeofest Apr 18 '13 at 11:34