开发者

Android app wont connect to anything

Like the title says, the app I've written (very simple, should load and display google.com) can't seem to connect out to the internet.

I wrote it in MOTODEV studio, it wouldn't connect from the emulator either but I was behind a proxy and knew this would happen. So I finished up, self-signed the .apk and transferred it to my GT-I5500 (Samsung galaxy europa). The apk installed just fine, but its not loading the page.

Just to be clear.... the regular browser on the phone loads anything just fine, I just can't seem to do so programatically from an app. I trawled this site, a bunch of Google hits and the android dev walkthroughs and no luck finding a solution my issue:(

Some code:

    package com.fooit.skifnews;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class Skifnews2Activity extends Activity {


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    WebView webView = new WebView(this);;

        webView.setWebChromeClient(new WebChromeClient());
        webView.setWebViewClient(new WebViewClient());
        webView.getSettings().setJavaScriptEnabled(true);
        String url="www.google.com";
        webView.loadUrl(url); 
        setContentView(webView);
    }
    }

and the manifest

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.fooit.skifnews"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.INTERNET"></uses开发者_如何学Go-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.INTERNET">
        <activity android:name=".Skifnews2Activity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

Any ideas why this might not be working? When run it returns me 404's which would suggest I'm not getting out since Google isn't down -.- Yet the standard browser gets out just fine. I'm omitting a bunch of files like R.java since I'm not actually using that yet for this simple app.... I haven't touched it anyway.. but it doesn't contain any mention of webview...can't see that it should be a problem.


Add this to your manifest, before the application tag:

<uses-permission android:name="android.permission.INTERNET" />


Have you tried changing:

String url="www.google.com";

To

String url="http://www.google.com";

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜