2014-09-25 68 views
0

在我的活動中,用戶會根據各種標準顯示另一個用戶。我試圖找出一種方法來提醒其他用戶,該用戶在當前用戶按鈕單擊時選擇了他。我在想,一旦用戶點擊確認按鈕,就會向用戶顯示一個警告對話框消息,以便他知道有人點擊確認了他。發送消息對話到另一個用戶

我正在使用Parse來管理用戶,下面是基於各種標準顯示用戶的代碼。

query1.findInBackground(new FindCallback<ParseUser>() { 
    @Override 
    public void done(List<ParseUser> objects,ParseException e) { 
     if (e == null) { 
      for(int i = 0; i < objects.size(); i++){ 
       // Do whatever you need to extract object from "users" 
       ParseQuery<ParseObject> query1 = ParseQuery.getQuery("User"); 
       query1.whereNotEqualTo("objectId", ParseUser.getCurrentUser(). 
        getObjectId()); 

       Button buttonconfirm = (Button) getView(). 
        findViewById(R.id.btnMatchConfirm); 
       buttonconfirm.setText("Confirm"); 

       mUserNameRetrieved = (TextView) getActivity(). 
        findViewById(R.id.userlistname); 

       mUserNameRetrieved.setText(objects.get(i).get("Name").toString()); 


       Button newPage = (Button)getView(). 
        findViewById(R.id.btnMatchConfirm); 
       newPage.setVisibility(View.VISIBLE); 
       newPage.setText("Confirm"); 
       newPage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); 

       newPage.setTextColor(Color.parseColor("#ff0000")); 
       newPage.setBackgroundColor(Color.TRANSPARENT); 

       ViewGroup.LayoutParams params = newPage.getLayoutParams(); 
       params.height = ViewGroup.LayoutParams.WRAP_CONTENT; 
       params.width = ViewGroup.LayoutParams.WRAP_CONTENT; 

       newPage.setLayoutParams(params); 

       newPage.setOnClickListener(new View.OnClickListener() { 
        @Override 
        public void onClick(View v) { 
        // ParseUser currentUser = ParseUser.getCurrentUser(); 
        // currentUser.put("UserMatchName", mUserRetrieved); 
         Intent intent = new Intent(getActivity(), 
          OptionActivity.class); 
         startActivity(intent); 
        } 
       });     
      } 
     } else if (e != null) {  

     } 
    } 
}); 

我不知道該從哪裏下去,任何澄清將不勝感激。 在此先感謝。

回答

1

如果您已經使用Parse,則應使用其推送通知。爲每個用戶註冊一個帶有頻道的接收器。 當用戶選擇另一個時,通知您的解析後端,然後通過所選通道從後端發送推送。

查看更多: https://parse.com/docs/android_guide#push

+0

感謝您的快速反應。我對使用Push持懷疑態度,因爲我最初認爲它只是通過通知更新用戶,而不是在應用內發送消息。 – John 2014-09-26 00:05:23

+0

你註冊一個接收器,然後你決定如何處理它,你可以顯示一個通知,或者你可以做任何你想做的事情 – RCB 2014-09-26 00:06:36