我使用下面的代码在facebook.com的一样的功能与我的Android应用程序集成。
第一:我使用所谓的FacebookLikeView.html一个HTML文件,我把它放在“资产/网络/”文件夹,这是我在它使用:
<html xmlns:fb="http://ogp.me/ns/fb#">
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src ="//connect.facebook.net/en_GB/all.js#xfbml=1&appId=My APP ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
</body>
<fb:like href="https://www.facebook.com/pages/OmarTalkcom/52242794400" send="true" width="120" show_faces="true" font="arial">
</fb:like>
</html>
然后我用一个按钮即可启动的HTML文件中像这样的网页视图:
Button like = (Button) findViewById(R.id.button1);
like.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
WebView myWebView = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("file:///android_asset/www/FacebookLikeView.html");
}
});
但没有happend并在日志中我得到了,当我按一下按钮如下:
04-28 09:33:56.940: D/CONTEXT(31684): nativeDraw called here
04-28 09:33:56.940: D/CONTEXT(31684): PictureSet* draw called here
04-28 09:33:56.940: V/(31684): In ResourceHandle::create newHandle
04-28 09:33:56.990: D/dalvikvm(31684): GC_CONCURRENT freed 103K, 4% free 7195K/7431K, paused 8ms+3ms
04-28 09:33:56.990: D/CONTEXT(31684): nativeDraw called here
04-28 09:33:56.990: D/CONTEXT(31684): PictureSet* draw called here
04-28 09:33:57.080: D/CONTEXT(31684): nativeDraw called here
04-28 09:33:57.080: D/CONTEXT(31684): PictureSet* draw called here
那么,我错在这里做或什么是为了喜欢的Android应用Facebook页面做正确的事?
请注意 ,我把上面的HTML代码的HTML文件,并与Chrome和Firefox打开它,但它没有工作,但它的工作时,我把它拷贝到下面的链接w3school HTML样品。