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. Adding iconified rows to existing ArrayAdapter

Hi,

I am developing an application which requires me to load first twenty
rows (consisting on icons and two text fields) and if I have more rows
I need to display a button. When i click this button I want to display
more twenty rows( again iconified).

My current approach which is working is that on the button click I
create one more activity which will have the previous rows and the new
rows. In this case the curson is set to the very first row.

But I want to have something like Facebooks "Older Post" where the new
rows get appended to the old ones and the cursor is set to the last
row to which the new rows are added.

Please can anyone give me ideas on how to achieve this. That is,  how
to add rows (iconified) to the existing array adapter.

Thanks,
Prajakta.

-- 

2. Changes to group moderation

Hi all,

We've just made some changes to the moderation settings for Android-
discuss and Android-beginners. From now on, requests to join the group
(to post and reply to messages) will be moderated for spam prevention
purposes. Messages themselves will no longer be moderated, and should
appear in the group shortly after posting.

So, for members who are just joining: your membership status will be
moderated to prevent spam, but once you join, you can post freely,
without a need to wait for moderation for your first message.

Thanks,

Roman Nurik
Android Developer Relations

-- 

3. How to start an Activity from a Service and getting a result from it

4. (More) Proxy Trouble

5. Intent to bring up top-most activity in task?

6. How to start an Activity from a Service and getting a result from it

7. Game Developers: Some general questions about high scores, achievements, multi player support and in game ads.