2

I am trying to create a proof-of-concept using where2getit and I have the following sample URL for Wafflehouse

http://hosted.where2getit.com/wafflehouse/indexnew.html

When I view in three different device modes:

  1. Desktop browser (Safari or Chrome tested)
  2. Android Mobile browser (Azpen / Acer mini-tablet running Jelly Bean)
    • notice the redirection to mobile....
  3. Android Native App in a WebView as URL or data; URL only, iFrame w/ src

The images that I get are as follows:

1. enter image description here

2. enter image description here

3. enter image description here

The code in the HomeActivity is:

    public class HomeActivity extends Activity {

    private static final String TAG = "HomeActivity";
    private static final String URL_LOADING = "http://mobile.where2getit.com/wafflehouse/indexnew.html";
    private static final String HTML_BODY = "<html>" + "<body>"
            + "<iframe id='content' src='http://hosted.where2getit.com/wafflehouse/indexnew.html' margin='5%' width='80%' height='80%'/>"
            + "</body>" + "</html>";
    private static final String MIME_TYPE = "text/html";
    private static final String ENCODING = "utf-8";
    private WebView mWebView;
    private MdWebChromeClient chromeClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        
        mWebView = (WebView) findViewById(R.id.webWhere2GetItIFrame);

        chromeClient = new MdWebChromeClient();
        mWebView.setWebChromeClient(chromeClient);
        mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        mWebView.getSettings().setAppCacheEnabled(false);
        mWebView.clearCache(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        // mWebView.addJavascriptInterface(new MdJsObject(), "injectedObject");
        mWebView.loadDataWithBaseURL("http://hosted.where2getit.com", HTML_BODY, MIME_TYPE, ENCODING, "");
        // mWebView.loadUrl(URL_LOADING);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.home, menu);
        return true;
    }

    final class ClickOnCallbackScript {

        private View mHandler;

        ClickOnCallbackScript() {
        }

        public void clickOnAndroid() {
            mHandler.post(new Runnable() {

                public void run() {
                    Log.d(TAG, "\t\tC L I C K . . .");
                    // mWebView.loadUrl("http://www.mobidawg.mobi/m/products/wethepeople/index.html");
                }
            });
        }

    }

}

Epilog

I am thinking that the problem may be related to properly using an IFRAME in a WebView; or a callback that I do not know how to detect and handle. I also believe the solution is simple and others have dealt with it.

If you can offer some thoughts for discussion, then an answer will likely will emerge.

Community
  • 1
  • 1
mobibob
  • 8,670
  • 20
  • 82
  • 131

1 Answers1

0

I can definitely tell you that the first 2 of your examples are different due to the way the OS presents itself to the website, and how then the website is coded to recognize and reply back to a desktop based web client versus a mobile based client. If you look at your android OS web browser picture, you will notice that your URL changed to begin with "mobile.". This is evidence that your Android OS web browser is presenting itself as a mobile client.

As for the custom app you have written, it may come down to a permission. Have you added

<uses-permission android:name="android.permission.INTERNET" />

to your permissions?

Im also not sure in your particular use case whether you need to use WebChromeClient.

Also found this on stack overflow for changing the "user agent" of your web client from within your custom app so that it can view the desktop version of a site.

Setting WebView to view Desktop Site and Not Mobile Site

Community
  • 1
  • 1
trumpetlicks
  • 7,033
  • 2
  • 19
  • 33
  • I was getting ready to reply, "of course my manifest permits INTERNET access.", But ... I cannot believe that I forgot that fundamental setting. It may have cost me 50 bonus points, but it has really put shame on my face. The screenshot for the Native App is now the same as the Android Browser's. Thanks for the User Agent link, I want to play around with that. I really thought there was an i-frame or callback issue. – mobibob Feb 18 '14 at 20:10
  • @mobibob - We ALL have done it where we know something, but just plain forget, or thought we incorporated, but didn't :-) I am glad that it triggered the fixing of the problem though, and I have to admit looking up the agent question made me think about incorporating that into a piece(s) of my code as well. – trumpetlicks Feb 18 '14 at 20:18