Facebook的授权不工作里面的Andr​​oid的AsyncTask或螺纹 [英] Facebook authorize not working inside Android Asynctask or Thread

查看:100
本文介绍了Facebook的授权不工作里面的Andr​​oid的AsyncTask或螺纹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与Facebook在Android的工作。有时候我申请兑现实时设备时,我试图授权的Facebook在Android.not的模拟器。我用了Android的Facebook SDK。所以我想线程可能会停止that.First试过的AsyncTask

Working with facebook in Android. Sometimes my application is cashing in real time device when I tried to authorize Facebook in Android.not in emulator. I used the Android Facebook SDK. So I thought threading might stop that.First tried the asynctask

Activity act=this;

private class fbwork extends AsyncTask<Facebook, Integer, String>
{

    @Override
    protected String doInBackground(Facebook... para)
    {
        // TODO Auto-generated method stub
        Log.d(tagg, "Entered async");
            if(loginflag==0)
            {
                try
                {
                    para[0].authorize(act, PERMISSIONS, new LoginDialogListener());
                }catch(Exception ex)
                {
                    Log.d(tagg,ex.getMessage());
                }
                Log.d(tagg, tagg.toString());
            }
            else
            {

                try {
                    logout();
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }


        return "0";
    }

调用code:

calling code:

new fbwork().execute(facebook);

产生错误:内螺纹尚未调用无法建立处理活套prepare()

于是尝试了正常的穿线方法。

So tried the normal threading way.

public void loginprocesure() throws MalformedURLException, IOException
{
    final Activity ac=this;
    if(loginflag==0)
    {
        new Thread(new Runnable() {

            public void run() {
                // TODO Auto-generated method stub
                facebook.authorize(ac, PERMISSIONS, new LoginDialogListener());
            }
        }).start();

    }
    else
    {

        logout();
    }
}

再次相同的结果。什么办法来解决这个问题!!!!如何停止在实际设备应用程序的崩溃。请大家帮帮忙。

推荐答案

我面临同样的issue.You必须尝试把这个方法在环

I faced the same issue.You must try to put this method in loop

 Looper.prepare();
 new fbwork().execute(facebook);
 Looper.loop();

这篇关于Facebook的授权不工作里面的Andr​​oid的AsyncTask或螺纹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆