无法使用Android访问我的本地Parse服务器

时间:2016-06-06 10:46:20

标签: android parse-platform parse-server

public class MainActivity extends ActionBarActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    ParseCloud.callFunctionInBackground("hello", new HashMap<String, Object>(), new FunctionCallback<String>() {
      @Override
      public void done(String object, com.parse.ParseException e) {
            System.out.println(object);
      }

    });

  }

StarterApplication

public class StarterApplication extends Application {

  @Override
  public void onCreate() {
    super.onCreate();
    Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
            .applicationId(getString(R.string.parse_app_id))
            .enableLocalDataStore()
            .server("http://localhost:1337/parse/")


    .build()
    );

  }
}

清单(如果需要)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.parse.starter" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:name=".StarterApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <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" />

        <activity
            android:name=".MainActivity"
            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>

它应返回一个字符串,但是返回null。我用PHP调用检查了这个。我究竟做错了什么?谢谢。

0 个答案:

没有答案