0

私はこのコードをランナブル内に持っています.Froyoではすべてが完全に機能します. しかし、ICS では接続すると表示されますが、ファイルが見つからないというエラーが表示され、ファイル サイズとして -1 が返されます。

認証を必要としないファイルは ICS で問題ありません。

ICS で認証する別の方法はありますか? または、ICS HttpURLConnection の詳細が不足していますか?

Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,pass);
                    }
                });
URL url = new URL(URLString);

HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();//connection says that it is connected
final int filesize = c.getContentLength();//file size is -1 when using ICS
c.disconnect();

また、Froyo で https URL への認証に問題がありますが、現時点では二次的な問題です..

できれば助けてくれてありがとう..

しばらく離れていましたが、今使っているのはこれです。ICSで動作します。現時点ではFroyoでテストしていないので、両方で動作するかどうかはわかりません...

    private void setAuthenticationCredentials(final String username, final String password) {
            Authenticator.setDefault(new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password
                            .toCharArray());
4

1 に答える 1