Parse.com says “no data yet” with actual device

2019-06-11 00:49发布

I am new to Parse.com and trying to the quick start project. I am following each and every step to build an app on android platform. But I am getting "no data yet" message everytime I click on Test button. What I've done so far is:

MainActivity:

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Parse.initialize(this, "AMRjGNY53W2HFZILS7M64rZy3b8mSz3qGkf1KeOE","xquKy2rT8FSeFYCd8A8mIVOCqqO5SlSMrCwlZ0ux");
    ParseAnalytics.trackAppOpened(getIntent());
    ParseObject testObject = new ParseObject("TestObject");
    testObject.put("foo", "bar");
    testObject.saveInBackground();
}}

My Application class is :

package com.example.hello1;

import android.app.Application;
import com.parse.Parse;

public class ParseApplication extends Application {

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

        // Add your initialization code here
        Parse.initialize(this, "AMRjGNY53W2HFZILS7M64rZy3b8mSz3qGkf1KeOE", "xquKy2rT8FSeFYCd8A8mIVOCqqO5SlSMrCwlZ0ux");
    }

and the manifest file :

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:name="ParseApplication"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name="com.example.hello1.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

After running the app when I click on test on parse.com, it says no data yet. !!

I don't understand what wrong I'm doing !!

3条回答
该账号已被封号
2楼-- · 2019-06-11 01:15

You can just try to see what happens when you try to save the object. The code below is an example to show how can you do that with a save callback.

I also encountered this problem and when i implemented this method, i found out that i get an https connection error. Later i see that my device's hosts file is blocking the api call.

    ParseObject testObject = new ParseObject("TestObject");
    testObject.put("foo", "bar");
    Log.e("PARSE.COM","DOWNLOAD STARTED");
    testObject.saveInBackground(new SaveCallback() {
        @Override
        public void done(ParseException e) {
            if (e != null) {
                Log.e("PARSE.COM","FAILED" + e.getMessage());
            }
            else
            {
                Log.e("PARSE.COM","SUCCESS");
            }
        }
    });
查看更多
The star\"
3楼-- · 2019-06-11 01:20

Use this code and try again, you need put Parse.initialize in the first line

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Parse.initialize(this, "AMRjGNY53W2HFZILS7M64rZy3b8mSz3qGkf1KeOE", "xquKy2rT8FSeFYCd8A8mIVOCqqO5SlSMrCwlZ0ux")
    ParseAnalytics.trackAppOpened(getIntent());
    ParseObject testObject = new ParseObject("TestObject");
    testObject.put("foo", "bar");
    testObject.saveInBackground();
}}
查看更多
地球回转人心会变
4楼-- · 2019-06-11 01:36

I had the same problem. Go to your manifest file and make sure that you application node is referencing your Java file.

For example you have your application class below

public class MyApplication extends Application {...}

in the AndroidManifest you need something like this...

 <application
  android:name="com.example.test.MyApplication"

That way your application file can be called by the application. =)

Make sure you use your fully qualified class name.

查看更多
登录 后发表回答