在android中设置parseUser的问题

时间:2017-11-05 00:06:08

标签: android parse-platform

我确定这是一个愚蠢的问题,但我正在尝试测试使用ParseUser添加测试用户。由于某种原因,它没有被添加到服务器。任何帮助表示赞赏。对不起,如果这看起来很明显,但我刚开始进行android编程。

活动

public class SignupActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signup);

        final ParseUser currentUser = new ParseUser();


        currentUser.setUsername("Test");
        currentUser.setPassword("xxx");
        currentUser.setEmail("Test@aol.com");
        currentUser.signUpInBackground(new SignUpCallback() {
            @Override
            public void done(ParseException e) {
                if (e == null){
                    Log.i("User added", "successful");
                }
            }
        });

}}

申请类

public class MainApplication extends Application {

    @Override
    public void onCreate(){
        super.onCreate();

        Parse.enableLocalDatastore(this);

        Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
                .applicationId("{I have actual app ID here}")
                .clientKey("{I have client key here}")
                .server("{It is here}")
                .build()
    );

        ParseObject parseObject = new ParseObject("FloridaLaw");


        ParseACL defaultACL = new ParseACL();
        defaultACL.setPublicReadAccess(true);
        defaultACL.setPublicWriteAccess(true);
        ParseACL.setDefaultACL(defaultACL, true);



    }
}

PrintTrace

11-04 19:56:44.678 22669-22669/? I/zygote: Not late-enabling -Xcheck:jni (already on)
11-04 19:56:44.718 22669-22669/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
11-04 19:56:45.206 22669-22669/com.ronaldpitt.floridalaw I/InstantRun: starting instant run server: is main process
11-04 19:56:45.520 22669-22676/com.ronaldpitt.floridalaw I/zygote: Waiting for a blocking GC ObjectsAllocated
11-04 19:56:45.672 22669-22680/com.ronaldpitt.floridalaw I/zygote: Background concurrent copying GC freed 7395(2MB) AllocSpace objects, 0(0B) LOS objects, 59% free, 1051KB/2MB, paused 3.900ms total 182.247ms
11-04 19:56:45.677 22669-22676/com.ronaldpitt.floridalaw I/zygote: WaitForGcToComplete blocked for 156.076ms for cause ObjectsAllocated
11-04 19:56:46.047 22669-22721/com.ronaldpitt.floridalaw I/OpenGLRenderer: Initialized EGL, version 1.4
11-04 19:56:46.049 22669-22721/com.ronaldpitt.floridalaw W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...

1 个答案:

答案 0 :(得分:0)

您是否已将申请类MainApplication.java添加到AndroidManifest.xml

<application
  android:name=".MainApplication"
  ...>
  ...
</application>

如果不能正常工作,请尝试直接在AndroidManifest.xml而不是应用类

中进行
<application ...>
  <meta-data
    android:name="com.parse.SERVER_URL"
    android:value="@string/parse_server_url" />
  <meta-data
    android:name="com.parse.APPLICATION_ID"
    android:value="@string/parse_app_id" />
  <meta-data
    android:name="com.parse.CLIENT_KEY"
    android:value="@string/parse_client_key"
  ...
</application>