0

私はアプリを開発しており、koush の lib Ion を使用しています: here

場合によってはうまく機能し、PHPファイルから「成功」または「ユーザーが既に存在します」という結果が得られ(エコー「成功」;)、結果が「」空の文字列になることもあります。

コードが多すぎるため、コード全体を投稿することはできませんが、その一部を求めることができます。Ion に精通していて、私を助けてくれる人はいますか?

public void registerNewUser(String fname, String lname, String email,
        String country, String aboutu, String uidenty, final Runnable r) {
    Ion.with(context,
            "http://project.com/index.php")
            .setBodyParameter("firstname", fname)
            .setBodyParameter("lastname", lname)
            .setBodyParameter("email", email)
            .setBodyParameter("country", country)
            .setBodyParameter("aboutu", aboutu)
            .setBodyParameter("useridentification", uidenty)
            .setBodyParameter("tag", "register").asString()
            .setCallback(new FutureCallback<String>() {

                @Override
                public void onCompleted(Exception ex, String res) {
                    if (ex != null) {
                        Log.e("ion-error", ex.getMessage());
                        Toast.makeText(
                                context,
                                "The registration failed. Try again later.",
                                Toast.LENGTH_LONG).show();
                    } else if ("succeed".equals(res.replace("\t", " ")
                            .trim())) {
                        r.run();
                    } else if ("User already exists".equals(res.replace(
                            "\t", " ").trim())) {
                        Toast.makeText(
                                context,
                                "This Email is already in use. Try another one.",
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
}
4

1 に答える 1

0

デバッグ中に例外が発生していますか? タイムアウト値を設定してみてください。

Ion.with(context,
        "http://project.com/index.php")
        .setBodyParameter("firstname", fname)
        .setBodyParameter("lastname", lname)
        .setBodyParameter("email", email)
        .setBodyParameter("country", country)
        .setBodyParameter("aboutu", aboutu)
        .setBodyParameter("useridentification", uidenty)
        .setBodyParameter("tag", "register")
        .asString()
        .setTimeout(20000)
        .setCallback(new FutureCallback<String>() {
         ........................your code.......
         }
于 2015-03-23T07:32:22.910 に答える