2012-06-04 34 views
1

我無法通過使應用程序與服務器進行通信來存儲數據的基礎知識。保存按鈕無法將數據上傳到解析

我試圖使用Parse(https://parse.com/)作爲我正在開發的Android應用程序的後端。我獲得了基本的「快速啓動」分析應用程序,並且能夠使用onCreate()方法將數據從手機上的應用程序上傳到我的Parse帳戶。然後,我嘗試創建一個應用程序,它可以在按下按鈕時上傳一些數據。我可以安裝並運行應用程序,但是當我按下按鈕時似乎沒有任何事情發生,然後當我檢查我的Parse帳戶時,沒有數據上傳。我包含了Parse庫,並將它們添加到構建路徑中。

這裏是應用程序代碼 -

package greg.mariani.saveLoad; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 

import com.parse.Parse; 
import com.parse.ParseObject; 

public class SaveLoad1Activity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     Parse.initialize(this, "private_app_token1", "private_app_token2"); 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
    } 

    public void saveUpdates(View view) { 
     ParseObject updates = new ParseObject("Updates"); 
     updates.put("court", "Brentwood Rec"); 
     updates.put("update", "Game On"); 
     updates.saveInBackground(); 
    } 
} 

這裏是佈局XML的

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/save" 
     android:onClick="saveUpdates"/> 

</LinearLayout> 

有人能看到我在做什麼錯?

回答

0

您是否已將互聯網權限添加到您的清單文件?

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

這似乎已經修好了!我不得不重新啓動項目並忘記了此權限。謝謝。 – gregamariani