Giter Site home page Giter Site logo

Comments (26)

Korriged avatar Korriged commented on March 29, 2024

Moreover it often gets the application to crash :\

from facebook-android-sdk.

soneff avatar soneff commented on March 29, 2024

Ya, this is a known issue, but it appears to be a non-trivial change to correct. If you have a simple fix, please send me a code diff and I will take a look; otherwise, sorry, I don't have an ETA for a fix. In the meantime, you can simply prevent your app from rotating by adding

android:screenOrientation="portrait"

as a property of your activity in the application manifest.

from facebook-android-sdk.

dnkoutso avatar dnkoutso commented on March 29, 2024

soneff, try to use setOwnerActivity() on the dialog itself. This should wire it up to the context and maintain the dialog ;)

from facebook-android-sdk.

dnkoutso avatar dnkoutso commented on March 29, 2024

http://developer.android.com/guide/topics/ui/dialogs.html

from facebook-android-sdk.

FacebbokAndroid avatar FacebbokAndroid commented on March 29, 2024

Hello,

Add this code in the manifest file for the Example activity. This will retrain the dialog when the orientation is changed.

android:configChanges="keyboardHidden|orientation"

from facebook-android-sdk.

emmby avatar emmby commented on March 29, 2024

This patch will at least act as a bandaid over the crash. I too would like to see a solution to the overall problem that doesn't involve manually handling configchanges

diff -r 44b3f51dfe41 facebook/src/com/facebook/android/FbDialog.java
--- a/facebook/src/com/facebook/android/FbDialog.java   Wed Jul 14 15:52:05 2010 -0400
+++ b/facebook/src/com/facebook/android/FbDialog.java   Wed Jul 14 16:18:27 2010 -0400
@@ -162,7 +162,11 @@
             if (title != null && title.length() > 0) {
                 mTitle.setText(title);
             }
-            mSpinner.dismiss();
+            try {
+                mSpinner.dismiss();
+            } catch( IllegalArgumentException ignored ) {
+                // thrown if the underlying activity was dismissed, eg. during device orientation change
+            }
         }   

     }

from facebook-android-sdk.

emmanueltouzery avatar emmanueltouzery commented on March 29, 2024

This solution:

android:configChanges="keyboardHidden|orientation"

Doesn't quite work well. In my case I attach a picture to the post and that picture makes the dialog taller. When rotating the screen when this option is activated, the buttons "publish" and "skip" disappear from the screen and the user cannot press them anymore, the only solution is to rotate the screen back. The dialog does not scroll.

This problem does not occur when the configChanges setting is not set (but then it crashes when the user rotates the screen too much...). And the layout is OK before rotation (OK when the phone is held vertically, OK when held horizontally, the problem comes after rotation).

The problem with not supporting rotation is that I must turn it off for my whole activity, it seems I can't do it for just this dialog. And the rest of that activity profits from screen rotation.

Also the try/catch workaround from emmby is not quite enough. The other dismiss at around line 127 still triggers the crash even after that try/catch is added. So I guess try/catch must be added in still other locations.

from facebook-android-sdk.

emmby avatar emmby commented on March 29, 2024

What's the status on this? The library consistently still crashes whenever a user changes their orientation.

from facebook-android-sdk.

Pretz avatar Pretz commented on March 29, 2024

I've fixed dialog rotation in my fork of facebook-android-sdk: http://github.com/Pretz/facebook-android-sdk

To fix it I had to change how you show the dialog; you'll need to use Activity.showDialog() and create the dialog in a separate step. I updated the simple example to do this.

from facebook-android-sdk.

jaredbro avatar jaredbro commented on March 29, 2024

Pretz,

I tried out your fix and the change to how you display the dialog and it worked correctly. Thanks for the fix!

Are there are lot of changes in your fork that might affect calls to the Facebook graph api, or are your changes simply fixing display issues? I'm trying to get an idea of how "safe" it is to take your branch or how much testing i should do with it.

Also, we should get that fix back in the official master!

from facebook-android-sdk.

Pretz avatar Pretz commented on March 29, 2024

jaredbro, I tried to keep my changes as minimal as possible. While it did require significantly changing how the dialog is displayed, I didn't touch any of the logic concerning the Graph API.

I've already sent a pull request to facebook; hopefully my changes can be integrated soon.

Cheers!

from facebook-android-sdk.

 avatar commented on March 29, 2024

Just having a play with Pretz branch because of the dialog issues it says its fixed.
The main difference that I can see is that rather than trying to keep the dialog open and reload it when orientation it just dismisses it, making the user have to click the button again.

from facebook-android-sdk.

 avatar commented on March 29, 2024

The Pretz branch fixes the problem if you wait for the content to finish loading but if you change orientation before the content has finished loading it leaks memory and crashes still.

from facebook-android-sdk.

Pretz avatar Pretz commented on March 29, 2024

@pteale I haven't been able to reproduce a crash while the webview is loading. Can you describe exactly what you did for that to happen? How did you show the dialog in the first place?

from facebook-android-sdk.

 avatar commented on March 29, 2024

@Pretz I was showing the dialog incorrectly, followed your example code and it works well. Deleting my previous post about the download part as its misleading

from facebook-android-sdk.

devunwired avatar devunwired commented on March 29, 2024

Really, the FbDialog code should not be written as a Dialog, but rather an Activity with Theme.Dialog applied to it. Then FB can achieve the partial screen coverage appearance they desire. but allowing the view to manage it's own state during rotation. Regardless, views that interact with a keyboard but do not support rotation might as well not exist because that is the ultimate UX fail on Android. Please fix this ASAP, or pull Pretz's fork.

from facebook-android-sdk.

Pretz avatar Pretz commented on March 29, 2024

@wirelessdesigns I agree. Unfortunately, I can no longer recommend my fork as it doesn't support instant connect through the Facebook app, and I don't plan on updating it to the latest facebook SDK features.

Until Facebook provides a better solution, I recommend having any activity that can launch fbDialog declare android:configChanges="keyboardHidden|orientation" in the manifest, which will keep the dialog on screen when the orientation changes. Unfortunately, if your activity depends on different resources for landscape/portrait, this could require a certain amount of work

from facebook-android-sdk.

wacheena avatar wacheena commented on March 29, 2024

Facebook: please develop a work around for this. Many Android devices have slide out keyboards and/or users that like to type in landscape mode. Forcing an app to stay in portrait just to avoid force close issues makes for a poor user experience.

from facebook-android-sdk.

sroorda avatar sroorda commented on March 29, 2024

This took me a while but I solved this in a similar fashion, although it required more than just setting the configChanges="orientation". Just adding that would keep the dialog on screen but it would keep it in its current orientation. In other words if you were in landscape with a landscape dialog and switched to portrait you would end up in portrait with a landscape dialog. Almost as bad as the crashing.

So, I did the following:

  • added a redraw() method to FbDialog that would redraw the dialog on request
  • in whatever activity I wanted to show the dialog I added the configChange="orientation" and in the onConfigurationChanged call I called the redraw() method.

This seems to work and have had no more reports of crashing in my app. I did not have to change anything else about how I showed the dialog or was using the API.
In addition to that I added a redraw() method to redraw the dialog

from facebook-android-sdk.

wacheena avatar wacheena commented on March 29, 2024

Thx sroorda. That could work. Can you post your FbDialog.redraw method?

from facebook-android-sdk.

Svetik avatar Svetik commented on March 29, 2024

I have one suggestion. It would be better if the dialog had the same layout for both orientations. Then the solution with android:configChanges="keyboardHidden|orientation" will work well. I think, it is the best solution for now, since it doesn't crash on orientation changes, the dialog looks nice for any display and any orientation, and it saves its state on orientation changes(if user has already entered his login or password)
technical details: mWebView should use WRAP_CONTENT layout. mContent should use WRAP_CONTENT or FILL_PARENT layout. it looks better, if subviews added to dialog when webView has already loaded.
Pretz, your solution more correctly, waiting for it! but in this case it also be better to have one layout for different orientations(in case of an activity doesn't recreates on rotation),as I suggest upper

from facebook-android-sdk.

PrinceManfred avatar PrinceManfred commented on March 29, 2024

Has there been any progress made on this issue?

from facebook-android-sdk.

guytavor avatar guytavor commented on March 29, 2024

reading this thread makes me feel embarraced for facebook.

from facebook-android-sdk.

sarp avatar sarp commented on March 29, 2024

Any news on this issue? It's unacceptable

from facebook-android-sdk.

EaseTheWorld avatar EaseTheWorld commented on March 29, 2024

I had a same issue when I use android:configChanges="keyboardHidden|orientation
To solve this, I modified FbDialog.java.

--mContent = new LinearLayout(getContext());
++mContent = new ConfigChangeLinearLayout(getContext(), this);

ConfigChangeLinearLayout is a custom LinearLayout which resizes when configuration changed.

private static class ConfigChangeLinearLayout extends LinearLayout {
private Dialog mDialog;
public ConfigChangeLinearLayout(Context context, Dialog dialog) {
super(context);
mDialog = dialog;
}

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        Display display = mDialog.getWindow().getWindowManager().getDefaultDisplay();
        final float scale =
            getContext().getResources().getDisplayMetrics().density;
        float[] dimensions =
            (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
                    ? DIMENSIONS_DIFF_LANDSCAPE : DIMENSIONS_DIFF_PORTRAIT;
        setLayoutParams(new FrameLayout.LayoutParams(
                display.getWidth() - ((int) (dimensions[0] * scale + 0.5f)),
                display.getHeight() - ((int) (dimensions[1] * scale + 0.5f))));         
    }
}

from facebook-android-sdk.

jamesgpearce avatar jamesgpearce commented on March 29, 2024

This issue was raised against an previous version of the Facebook SDK for Android.

In 2012, the SDK had a significant rewrite and relaunch, and we are closing issues and pull requests that predate that v3.0 release.

If you are still experiencing this issue, please raise a new issue with repro steps in the supported SDK (currently v3.6). For more information, please see our Android developer center at https://developers.facebook.com/docs/android.

Many thanks for using the Facebook Platform, and your support of this project.

from facebook-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.