HTML login form works in Android browser and fails with WebView ?

by Derek » Mon, 02 Mar 2009 04:03:47 GMT


Sponsored Links
 Hi all,

I'm facing the following problem. I'm opening Flickr HTML login form
with default Android browser and everything works fine when I'm
logging (click "sign in" button in HTML form):
 String url = " http://m.flickr.com/" ;;
 Intent intent = new Intent();
 intent.setAction(Intent.ACTION_VIEW);
 intent.setData(Uri.parse(url));
 startActivity(intent);

But "sign in" button does nothing when using the same in a WebView:
String url = " http://m.flickr.com/" ;;
 WebView webview = (WebView) findViewById(R.id.flickr_authwebview);
 webview.getSettings().setJavaScriptEnabled(true);
 webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
 webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
 webview.getSettings().setLoadsImagesAutomatically(false);
 webview.setClickable(true);
 webview.loadUrl(url);

What could be the problem ?
--~--~---------~--~----~------------~-------~--~----~



HTML login form works in Android browser and fails with WebView ?

by Derek » Mon, 02 Mar 2009 04:08:27 GMT


 To get the login form, use:
String url = " http://m.flickr.com/signin/" ;;



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


HTML login form works in Android browser and fails with WebView ?

by Derek » Mon, 02 Mar 2009 23:14:29 GMT


 Anyone ?
Even simple links are not followed.





--~--~---------~--~----~------------~-------~--~----~



HTML login form works in Android browser and fails with WebView ?

by Miguel Paraz » Tue, 03 Mar 2009 18:13:20 GMT


 





Hi,
WebView requires that your manifest has:
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>


--~--~---------~--~----~------------~-------~--~----~



HTML login form works in Android browser and fails with WebView ?

by Derek » Wed, 04 Mar 2009 04:49:49 GMT


 eah, thanks ! I was using layout_weight="1.0". I've removed it and
now the links are working. However, the login form still doesn't work
as in Android browser.
When I look to the source it seems very simple (No JavaScript). Some
form fields are hidden and empty. Could it be the problem ?

Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/flickr_authwebview_title_label"
android:layout_marginBottom="6px"/>

<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">

<Button android:id="@+id/flickr_authwebview_button_ok"
android:text="@string/flickr_authwebview_ok_button"
android:layout_marginRight="10px"
android:layout_marginTop="6px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<Button android:id="@+id/flickr_authwebview_button_cancel"
android:text="@string/flickr_authwebview_cancel_button"
android:layout_marginLeft="10px"
android:layout_marginTop="6px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

<WebView
android:id="@+id/flickr_authwebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

</LinearLayout>

and my code:
String url = "http://m.flickr.com/signin/";
WebView webview = (WebView) findViewById(R.id.flickr_authwebview);
webview.setWebViewClient(new AuthWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.loadUrl(url);
webview.setClickable(true);
webview.requestFocus();


private class AuthWebViewClient extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String
url)
{
view.loadUrl(url);
return true;
}
}

Thanks for any help.


On Mar 3, 11:40am, for android <forandr...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



HTML login form works in Android browser and fails with WebView ?

by Derek » Wed, 04 Mar 2009 19:14:54 GMT


 hanks but the problem is still here. However, If i remove:
webview.setWebViewClient(new AuthWebViewClient());
then I notice that with setSupportMultipleWindows(true); it opens a
new Android browser windows when I click to "Submit" button but the
page displayed is not the correct one. I'm wondering if Flickr is able
to check that the HTML is loaded into a WebView or a real browser (as
for in iFrame). I don't see how because there is no JavaScript in the
HTML.

Any other suggestions ?


On Mar 4, 8:30am, for android <forandr...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



HTML login form works in Android browser and fails with WebView ?

by Derek » Thu, 05 Mar 2009 06:02:55 GMT


 es, that's I did in the code I've posted before. I don't see the
difference ?
Could this issue come from Cookie management in WebView ? Is there any
option to make sure cookies are passed ?

Thanks.


On Mar 4, 12:34pm, for android <forandr...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. error on Oauth on android

private void authpost(String verificationCode) throws
OAuthMessageSignerException, OAuthNotAuthorizedException,
OAuthExpectationFailedException, OAuthCommunicationException,
IOException{
        /*Creates a consumer object and configure it with access
         * token and token secret still needed from service I HAVE NO
IDEA
         * WHAT THEY ARE*/

        OAuthConsumer consumer = new CommonsHttpOAuthConsumer(
                CONSUMER_KEY, CONSUMER_SECRET,
SignatureMethod.HMAC_SHA1);
          Log.i("cliqdroid", "Finished consumer loading function");
          consumer.setTokenWithSecret(ACCESS_TOKEN, TOKEN_SECRET);


        //Http request to the protected resource
        URL url = new URL("https://api.cliqset.com/200905/user/radzell/
profile");
        HttpURLConnection request = (HttpURLConnection) url.openConnection
();

        //sign the request so it can get past the security
        consumer.sign(request);

        //send the request to the server in order to obtain access to
resource
        request.connect();

        String responsecode = request.getResponseMessage();

        Log.i("Cliqdroid", responsecode);

        // create a new service provider object and configure it with
        // the URLs which provide request tokens, access tokens, and
        // the URL to which users are sent in order to grant
permission
        // to your application to access protected resources

        OAuthProvider provider = new DefaultOAuthProvider(consumer,
                REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL,
                AUTHORIZE_WEBSITE_URL);

         // fetches a request token from the service provider and builds
        // a url based on AUTHORIZE_WEBSITE_URL and CALLBACK_URL to
        // which your app must now send the user
        @SuppressWarnings("unused")
                String url1 = provider.retrieveRequestToken(OAuth.OUT_OF_BAND);

        provider.retrieveAccessToken(verificationCode);


    }
The emulator keep saying the program unexpectically stopped
--~--~---------~--~----~------------~-------~--~----~

2. Android video and the browser

This may not be the proper place but I've yet to find the answer! How
should I develop website so that when a user click on a link to my
video it will play ? Embed codes work on the iPhone, but they display
a broken plugin sign on the android and the gears concept doesn't
enable me to tell the bowser to load it in the media player. I tried
putting a direct link to the file but it does nothing.

I just want to enable android users to view films from my web site!
we've managed to do it for the iphone so ... why not ?

Cheers,

Stephane
--~--~---------~--~----~------------~-------~--~----~

3. Should we use jade androide to develop application?

4. Timeout executing service - how to avoid this?

5. Low accuracy of the accelerometer Sensor

6. Change RamDisk size

7. GPS on G1/G2