Facebook事件在移动设备上测试时会造成崩溃

时间:2012-12-13 06:06:07

标签: android facebook emulation

我有以下代码在facebook上创建一个事件。它在模拟器上工作正常但在手机中崩溃(Sony Miro):

 private void createEvents()
        {
            try
            {

                mPrefs = getPreferences(MODE_PRIVATE);
                String accessToken = mPrefs.getString("access_token", null);
                facebookatEventCreate.setAccessToken(accessToken);
                long expires = mPrefs.getLong("access_expires", 0);

                if (accessToken != null)
                {
                    facebookatEventCreate.setAccessToken(accessToken);
                }

                if (expires != 0)
                {
                    facebookatEventCreate.setAccessExpires(expires);
                }

                if (!facebookatEventCreate.isSessionValid())
                {
                    facebookatEventCreate.authorize(this, new String[] {
                        "email", "publish_stream", "create_event"
                    }, new DialogListener()
                    {

                        @Override
                        public void onCancel()
                        {
                            // Function to handle cancel event
                        }

                        @Override
                        public void onComplete(Bundle values)
                        {
                            // Function to handle complete event
                            // Edit Preferences and update facebook acess_token
                            SharedPreferences.Editor editor = mPrefs.edit();
                            editor.putString("access_token", facebookatEventCreate.getAccessToken());
                            editor.putLong("access_expires", facebookatEventCreate.getAccessExpires());
                            editor.commit();
                        }

                        @Override
                        public void onError(DialogError error)
                        {
                            // Function to handle error

                        }

                        @Override
                        public void onFacebookError(FacebookError fberror)
                        {
                            // Function to handle Facebook errors

                        }

                    });
                }



                //getting the event name from the text box
                String eventName = txtEventName.getText().toString();
                Log.d("createEvent:createEvent", "Event Name->"+ eventName);

                //getting the event location from the text box
                String eventLocation = txtEventLocation.getText().toString();
                Log.d("createEvent:createEvents", "Event Location->"+ eventLocation);

                //getting the event description from the text box
                String eventDescription = txtEventDescription.getText().toString();
                Log.d("createEvent:createEvents", "Event Description->"+eventDescription);               


                //this is the date of the event picked from the dialog
                //Log.d("createEvent:createEvents", "new Time->" + startDate);
                startDateAndTime = startDate + startTime;
                Log.d("createEvent:createEvents", "DATE AND TIME->"+startDateAndTime);



                Bundle params = new Bundle();
                params.putString("name", eventName);
                params.putString("start_time", startDateAndTime);
                //params.putString("end_time", "2013-12-02T20:00:00+0530");
                params.putString("description", eventDescription);
                params.putString("location", eventLocation);
                params.putString("privacy_type", "OPEN");

                mAsyncRunner1.request("me/events", params, "POST", new RequestListener()
                {

                    @Override
                    public void onMalformedURLException(MalformedURLException e, Object state)
                    {

                    }

                    @Override
                    public void onIOException(IOException e, Object state)
                    {

                    }

                    @Override
                    public void onFileNotFoundException(FileNotFoundException e, Object state)
                    {

                    }

                    @Override
                    public void onFacebookError(FacebookError e, Object state)
                    {

                    }

                    @Override
                    public void onComplete(String response, Object state)
                    {
                        try
                        {
                            JSONObject event = new JSONObject(response);
                            eventID = event.getString("id");
                            Log.d("createEvent:createEvent", "Event ID->" + eventID);
                            Log.i(response, response);

                           //Toast.makeText(getApplicationContext(), "New Event Created!!", Toast.LENGTH_LONG).show();
                        }
                        catch (Exception e)
                        {

                        }
                    }
                }, null);
            }
            catch (Exception e)
            {

            }
        }

我在logcat上收到以下消息,这些消息在使用模拟器进行调试时从未见过:

12-13 11:26:01.019: I/Adreno200-EGLSUB(6360): <ConfigWindowMatch:2081>: Format RGBA_8888.
12-13 11:26:01.029: D/memalloc(6360): /dev/pmem: Mapped buffer base:0x51832000 size:614400 offset:0 fd:67
12-13 11:26:01.179: D/memalloc(6360): /dev/pmem: Mapped buffer base:0x51b51000 size:2396160 offset:1781760 fd:70
12-13 11:26:02.259: D/memalloc(6360): /dev/pmem: Mapped buffer base:0x51e9a000 size:3010560 offset:2396160 fd:73
12-13 11:26:02.399: D/-heap(6360): GC_FOR_ALLOC freed 125K, 16% free 6562K/7775K, paused 21ms
12-13 11:26:02.499: D/-heap(6360): GC_CONCURRENT freed 3K, 8% free 15558K/16803K, paused 2ms+2ms

而且:

12-13 11:26:17.899: E/ActivityThread(6360): Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider

有了这个应用程序崩溃:

12-13 11:26:18.979: V/WebRequest(6360): WebRequest::WebRequest, setPriority = 1
12-13 11:26:19.159: E/WindowManager(6360): Activity com.hsenid.eventer.ui.createEvent has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41b70728 that was originally added here
12-13 11:26:19.159: E/WindowManager(6360): android.view.WindowLeaked: Activity com.hsenid.eventer.ui.createEvent has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41b70728 that was originally added here
12-13 11:26:19.159: E/WindowManager(6360):  at android.view.ViewRootImpl.<init>(ViewRootImpl.java:345)
12-13 11:26:19.159: E/WindowManager(6360):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:268)
12-13 11:26:19.159: E/WindowManager(6360):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:216)
12-13 11:26:19.159: E/WindowManager(6360):  at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:141)
12-13 11:26:19.159: E/WindowManager(6360):  at android.view.Window$LocalWindowManager.addView(Window.java:537)

请让我知道我该怎么做...提前谢谢你!

1 个答案:

答案 0 :(得分:0)

尝试使用严格模式

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder() .permitAll().build(); StrictMode.setThreadPolicy(policy);

如果您的清单文件中的doesent工作发生了变化

android:minSdkVersion="yourminumsdkhere"
    android:targetSdkVersion="yourmaximumsdkhere" 

android:minSdkVersion="yourminumsdkhere" android:targetSdkVersion="yourminumsdkhere"

我认为StrictMode会帮助你。还有一个建议是你在网络操作期间弹出多个窗口。也可能导致崩溃,如日志猫所示。 谢谢