我已经尝试将数据放入Parse Cloud好几天了,但我真的不明白为什么它不起作用。
我包含了两个libs(Parse和bolts android),并在网上学习了几个教程。我的代码如下:
package com.dannyvdz.testapp2;
import android.app.Activity;
import android.os.Bundle;
import com.parse.Parse;
import com.parse.ParseObject;
public class ParseApplication extends Activity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.parseapplication);
Parse.initialize(this, "************", "************");
// Test creation of object
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
}
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dannyvdz.testapp2">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".ParseApplication"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
该应用程序编译和运行没有错误,但没有代码发送到Parse.com。我尝试从Android studio运行该应用程序,并在构建后使用adb安装后运行。我似乎不明白自己做错了什么。任何帮助都将不胜感激,因为我认为我的头发开始变灰了。。。
您确定(模拟器或设备)上有互联网连接吗??
你能试试吗:
testObject.saveEventually();
更改为:
testObject.saveInBackground();
我不确定为什么,但该应用程序可以在我的平板电脑和android模拟器上运行,所以问题出在我的手机上。我想我应该在工厂重置我的手机(或者等待我的新nexus 6,在此期间使用我的平板电脑)。谢谢你的帮助!
更新:几天后,我再次查看了Logcat,发现了一些消息,让我想起了我的android广告拦截程序(adfree)。我禁用了adfree,它又开始工作了。至少我想通了!