Android - Completely independent native WebView - shouldOverrideUrlLoading never called

642 views
Skip to first unread message

David Martinez

unread,
Sep 13, 2011, 11:23:49 PM9/13/11
to rhomobile
I have an app in rhodes 3.0.2 that uses the Facebook SDK at
https://github.com/facebook/facebook-android-sdk in order to do some
sharing.

Facebook SDK is initialized by creating a dialog -
https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/FbDialog.java
that points to m.facebook.com using https

On my native code (called by adding a simple JavascriptInterface, to
keep things rho-less for this particular area), I prepare my bundle,
then do:

facebook.dialog(RhodesActivity.getContext(), method,
bundle, new Facebook.DialogListener() {

So far so good. I can show the dialog and the [Cancel] [Share] buttons
show up. I type some stuff then I click either button.

Now the way FacebookDialog communicates back is by setting a
WebViewClient on the private dialog WebView and checking that the Url
starts with a special prefix fbconnect:// (see FBDialog.java and
Facebook.java on that same folder):

public boolean shouldOverrideUrlLoading(WebView view, String
url) {
Log.d("Facebook-WebView", "Redirect URL: " + url);
if (url.startsWith(Facebook.REDIRECT_URI)) {
// Do some magic, close the box, etc.

This all works great, and my post gets to Facebook, but for some
reason shouldOverrideUrlLoading never gets called on the
WebViewClient. I have tried this same thing with the default examples,
and they all seem to work fine.

Could the RhodesActivity be interfering somehow? According to Android
WebKit's CallbackProxy class, an OVERRIDE_URL message is sent (on the
working example version) with a Bundle[{url=fbconnect://success?
post_id=(fbpostid)#_=_}] as the object argument. But it doesn't look
like the message is ever being sent or received when running rhomobile
as the controlling activity.

Please let me know what you think.

Raúl Alejandro Véjar Llugany

unread,
Sep 14, 2011, 9:10:51 AM9/14/11
to rhom...@googlegroups.com
What return url are u using?


--
You received this message because you are subscribed to the Google Groups "rhomobile" group.
To post to this group, send email to rhom...@googlegroups.com.
To unsubscribe from this group, send email to rhomobile+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhomobile?hl=en.


David Martinez

unread,
Sep 14, 2011, 12:35:37 PM9/14/11
to rhomobile
Hi Raúl,

I'm using the default return url as defined in facebook/src/com/
facebook/android/Facebook.java - fbconnect://success or fbconnect://


public static final String REDIRECT_URI = "fbconnect://success";
public static final String CANCEL_URI = "fbconnect://cancel";

None of the Urls ever seem to pass through shouldOverrideUrlLoading
though.



On Sep 14, 6:10 am, Raúl Alejandro Véjar Llugany
<raul.ve...@gmail.com> wrote:
> What return url are u using?
>
>
>
>
>
>
>
> On Tue, Sep 13, 2011 at 11:23 PM, David Martinez <dmarti...@wurl.com> wrote:
> > I have an app in rhodes 3.0.2 that uses the Facebook SDK at
> >https://github.com/facebook/facebook-android-sdkin order to do some
> > sharing.
>
> > Facebook SDK is initialized by creating a dialog -
>
> >https://github.com/facebook/facebook-android-sdk/blob/master/facebook...

Raúl Alejandro Véjar Llugany

unread,
Sep 14, 2011, 12:48:13 PM9/14/11
to rhom...@googlegroups.com
Mmmm... I better let someone with more experience using the Android Facebook SDK answer this.
I was looking for a multi-platform solution for facebook integration so I discarded the sdks right of the bat but I couldn't get the javascript sdk to work properly either because of the url rewriting rhodes does. It might have something to do with that although I'm not entirely sure how you are exposing the sdk to rhodes... as a native extension I suppose.
 
The way that I know integration with Facebook works is to use the dialog and graph apis directly, check this discussion for it:
 

David Martinez

unread,
Sep 14, 2011, 2:16:22 PM9/14/11
to rhomobile
Thanks, Raul,

I was also originally looking for a multi platform solution and came
across that thread. However the more I saw it the more I ended up
thinking that for my limited needs using the SDKs was going to end up
resulting in less integration points than trying to do a redirect
"thing" on the server and write a whole UI myself to do the
integration manually. That's essentially what the SDKs do. Plus the
deeper integration (single-sign-on for example) that the native SDKs
provide was going to end up being a better experience than an
eventually expiring cookie on the web.

BTW, the integration is inside a native extension, but publishing it
as a JavascriptInterface. It was the quickest way, I may go to a full
swig ruby integration if I end up doing deeper things that require me
to MVC it.

That's why I titled the post the way I did, because the underlying
problem is that a completely independent WebView with WebViewClient,
using RhodesActivity as its controlling activity, never gets its
shouldOverrideUrlLoading called. The fact that it's the very common
Facebook SDK dialog is kind of a side effect that let's you more or
less easily try it yourself.

I would love to know why and a solution from a Rhomobile expert :-)

Thanks!


On Sep 14, 9:48 am, Raúl Alejandro Véjar Llugany
<raul.ve...@gmail.com> wrote:
> Mmmm... I better let someone with more experience using the Android Facebook
> SDK answer this.
> I was looking for a multi-platform solution for facebook integration so I
> discarded the sdks right of the bat but I couldn't get the javascript sdk to
> work properly either because of the url rewriting rhodes does. It might have
> something to do with that although I'm not entirely sure how you are
> exposing the sdk to rhodes... as a native extension I suppose.
>
> The way that I know integration with Facebook works is to use the dialog and
> graph apis directly, check this discussion for it:
>
> http://groups.google.com/group/rhomobile/browse_thread/thread/887c4f4...
>
> Hope that helps
>
>
>
>
>
>
>
> On Wed, Sep 14, 2011 at 12:35 PM, David Martinez <dmarti...@wurl.com> wrote:
> > Hi Raúl,
>
> > I'm using the default return url as defined in facebook/src/com/
> > facebook/android/Facebook.java - fbconnect://success or fbconnect://
>
> >    public static final String REDIRECT_URI = "fbconnect://success";
> >    public static final String CANCEL_URI = "fbconnect://cancel";
>
> > None of the Urls ever seem to pass through shouldOverrideUrlLoading
> > though.
>
> > On Sep 14, 6:10 am, Raúl Alejandro Véjar Llugany
> > <raul.ve...@gmail.com> wrote:
> > > What return url are u using?
>
> > > On Tue, Sep 13, 2011 at 11:23 PM, David Martinez <dmarti...@wurl.com>
> > wrote:
> > > > I have an app in rhodes 3.0.2 that uses the Facebook SDK at
> > > >https://github.com/facebook/facebook-android-sdkinorder to do some
Reply all
Reply to author
Forward
0 new messages