简体   繁体   English

我的应用程序中的 Facebook 共享在摩托罗拉 Droid 上崩溃?

[英]Facebook sharing from my app crashes on Motorola Droid?

I have developed an app that allows to post data on the facebook wall using facebook sdk.I have tested on a few other phones like LG optimus but when the app runs on the motorola droid it crashes at times.我开发了一个应用程序,允许使用 facebook sdk 在 facebook 墙上发布数据 facebook 墙上。我已经在其他一些手机上测试过,比如 LG Optimus,但有时它会在应用程序上崩溃。

When i click on the share facebook button in my context menu the app crashes.当我单击上下文菜单中的共享 facebook 按钮时,应用程序崩溃。

I have googled and found out this much我用谷歌搜索并发现了这么多

http://groups.google.com/group/android-developers/browse_thread/thread/92d6f063682d2ca4/735acce1300115d7?show_docid=735acce1300115d7&pli=1 . http://groups.google.com/group/android-developers/browse_thread/thread/92d6f063682d2ca4/735acce1300115d7?show_docid=735acce1300115d7&pli=1

There is a problem with Droid phones when using web kit.使用 web 套件时,Droid 手机出现问题。

The same issue was reported on facebook sdk https://github.com/facebook/facebook-android-sdk/issues/82?authenticity_token=a321076df454835ad9c481d6fa73a3ea8cad1ceb The same issue was reported on facebook sdk https://github.com/facebook/facebook-android-sdk/issues/82?authenticity_token=a321076df454835ad9c481d6fa73a3ea8cad1ceb

Again it is mostly said that the exception has occurred during the use of motorola droid.再次,大多数人说在使用摩托罗拉机器人期间发生了异常。

Here is the stack Trace:这是堆栈跟踪:

java.lang.NullPointerException
    at android.webkit.WebView.onWindowFocusChanged(WebView.java:4177)
    at android.view.View.dispatchWindowFocusChanged(View.java:3788)
    at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:658)
    at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662)
    at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662)
    at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1921)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    at dalvik.system.NativeStart.main(Native Method)

Does someone have a solution or workaround to this?有人对此有解决方案或解决方法吗?

Edit:This seems to be happening on HTC Incredible also.编辑:这似乎也发生在 HTC Incredible 上。

There is a work around for this which explicitly mentions the Motorola Droid you can find the original posting at:有一个解决方法明确提到了摩托罗拉 Droid,您可以在以下位置找到原始帖子:

Workaround for Null Pointer Excpetion in WebView.onWindowFocusChangedWebView.onWindowFocusChanged 中 Null 指针异常的解决方法

Create a custom webclass:创建一个自定义网络类:

CustomWebView.java CustomWebView.java

public class CustomWebView extends WebView {

    public CustomWebView(Context context) {
        super(context);
    }

    public CustomWebView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public CustomWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        try{
            super.onWindowFocusChanged(hasWindowFocus);
        }catch(NullPointerException e){
        // Catch null pointer exception
        }
    }
}

Now open up the FbDialog.java provided by facebook and modify the line that creates the webview to use the the CustomWebView subclass as follows现在打开 facebook 提供的 FbDialog.java 并修改创建 webview 的行以使用 CustomWebView 子类,如下所示

WebView view = new CustomWebView(getContext());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM