Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old July 16th, 2011, 04:39 PM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Feb 2011
Location: Ukraine, CK
Posts: 31
 
Device(s): Galaxy Tab 10.1 Galaxy Nexus
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via ICQ to vovs Send a message via Skype™ to vovs
Default troubles with webview + facebook

Hi, guys!
Have some problem:
I create simple Activity with webview.
If you visit Facebook Mobile, you will notice that you can scroll to the bottom of the page and when you do, more loads posts - via default browser. But this is not working in my webview.

The other thing that also needs to be fixed is the "More" button on the top right corner. The menu itself works when you touch the "more" button but none of the menu items are clickable in my webview.
Can anyone help me?

code here:

Code:
public class FacebookProjActivity extends Activity {

	WebView webview;
	public String url = "http://m.facebook.com";
	public String oldUrl;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        webview = (WebView) findViewById(R.id.webview);
        //String myUserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7";
		//webview.getSettings().setUserAgentString(myUserAgent);
		
		webview.getSettings().setSavePassword(true);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setJavaScriptCanOpenWindowsAutomatically (true);
        webview.getSettings().setAppCacheEnabled(true); 
        webview.getSettings().setPluginsEnabled(true);
		webview.getSettings().setSupportMultipleWindows (true);
		webview.getSettings().supportZoom();
		webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
		webview.getSettings().setLightTouchEnabled(true);
        webview.setWebViewClient(new FacebookProWebViewClient());
        webview.loadUrl("http://m.facebook.com");
	}			
	@Override
	protected void onDestroy() {   
		super.onDestroy();
	}
	
	private class FacebookProWebViewClient extends WebViewClient {
	    @Override
	    public boolean shouldOverrideUrlLoading(WebView webview, String url) {
	    	if (webview.getUrl().startsWith("http://m.facebook") == true){
	    		webview.loadUrl(url);
		        return true;
	    	}else{
	    		return false;
	    	}
	    }
	    public void onFormResubmission (WebView webview, Message dontResend, Message resend){
	    }
	    public void onLoadResource (WebView webview, String url){
	    }
	}
}
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
>
  <WebView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  />
</LinearLayout>

vovs is offline  
Reply With Quote
sponsored links
Old July 18th, 2011, 07:01 AM   #2 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Feb 2011
Location: Ukraine, CK
Posts: 31
 
Device(s): Galaxy Tab 10.1 Galaxy Nexus
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via ICQ to vovs Send a message via Skype™ to vovs
Default

same result if use this code:

Code:
import android.app.Activity;
import android.os.Bundle;
import android.os.Message;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class FacebookProjActivity extends Activity {

        WebView webview;
        public String url = "http://m.facebook.com";
        public String oldUrl;

        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        webview = (WebView) findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.setWebViewClient(new FacebookProWebViewClient());
        webview.loadUrl("http://m.facebook.com");
        }
        @Override
        protected void onDestroy() {
                super.onDestroy();
        }

        private class FacebookProWebViewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView webview, String url) {
                        webview.loadUrl(url);
                        return true;
            }
        }
}
any suggestions?
vovs is offline  
Reply With Quote
Reply
Tags
webview


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:56 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.