gpt4 book ai didi

java - 解析 SignUpCallback() 方法错误

转载 作者:行者123 更新时间:2023-12-01 11:58:46 24 4
gpt4 key购买 nike

我正在尝试按照 https://www.parse.com/apps/quickstart#social/mobile/android/native/existing 上的快速入门指南进行操作,并添加一个用户,以便我可以测试它并确保一切正常。当我到达这一部分时

    user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});

我在新的 SignUpCallBack() 方法上收到错误。它表示我必须在 SignUpCallBack 中声明它抽象或实现抽象方法 did(ParseException)。我不知道如何解决它。我认为必须导入 SignUpCallBack,但它已经这样了,现在我不知道该怎么办。

这是它所在的整个 Activity 类。

 package interested.social.com.interested;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.parse.Parse;
import com.parse.ParseUser;
import com.parse.SignUpCallback;

import java.text.ParseException;


public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Parse.initialize(this, "PjeUs8h1gJqgFgk48ptUUp7QqyyFOXxTYriwjCVu", "0lj44wRi0xHhOmSTtfpAcxyBlZKuzBX23J95wzAL");


ParseUser newUser = new ParseUser();
newUser.setUsername(username);
newUser.setPassword(password);
newUser.setEmail(email);
newUser.signUpInBackground(new SignUpCallback() {

@Override
public void done(ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});


}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}

}

最佳答案

您需要在 done 方法上方添加 @Override 装饰器,如下所示,否则它不知道您正在实现正确的方法:

user.signUpInBackground(new SignUpCallback() {
@Override
public void done(com.parse.ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});

也尝试使用 com.parse.ParseException e 而不是 ParseException e 作为上面发布的 done() 方法的参数。当然,不要忘记为 setUsernamesetPasswordsetEmail 分配值。

关于java - 解析 SignUpCallback() 方法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28139931/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com