将当前用户的数据显示给其他用户

时间:2014-12-29 15:26:22

标签: java android database parsing

我的应用程序是一个献血应用程序,首先我们从用户那里获取信息,将其保存到Parse.com数据库中。然后将这些数据显示为2个不同的列表视图,如捐赠者和接受者, 现在,当用户从列表中单击任何一个用户时,该当前用户的数据将通过通知发送给该列表中提到的用户。请求的用户通过活动获取通知,现在问题即将到来,我无法将该活动上显示的数据提供给被请求的用户。

      //This is the reciver class that's opening that acitivty to the requested user


    private static final String TAG = "Receiver";
      @Override
     public void onReceive(Context arg0, Intent arg1) {
    // TODO Auto-generated method stub


      try {
            ParseObject perseonj = new ParseObject(arg1.getExtras().getString(
                    "com.parse.Data"));

            String event_id = ParseUser.getCurrentUser().getObjectId();

            Intent eventIntent = new Intent(arg0, ShowPopUp.class);
            eventIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
           eventIntent.putExtra("id", event_id);

           String struser = ParseUser.getCurrentUser().getUsername().toString();
           String bg = ParseUser.getCurrentUser().getString("BloodGroup").toString();


            Intent i = new Intent();
               i.putExtra("idd", struser.toString());
              i.putExtra("bg", bg.toString());  

            arg0.getApplicationContext().startActivity(eventIntent);
            System.out.println(event_id);

        } catch (android.net.ParseException e) {
            Log.d(TAG, "PARSEException: " + e.getMessage());
        }

       }

       }

    // This is the acitivty which actually displays the data


    public class ShowPopUp extends Activity implements OnClickListener
        {
     @Override
       protected void onCreate(Bundle savedInstanceState) {
     // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setTitle("COPAN");
        setContentView(R.layout.popupdialog);


       TextView tv = (TextView) findViewById(R.id.textView1);
      final String current = getIntent().getExtras().getString("idd");
     tv.setText(current);

      TextView vtv = (TextView) findViewById(R.id.textView3);
      final String currentt = getIntent().getExtras().getString("bg");
     vtv.setText(currentt); 

         }

1 个答案:

答案 0 :(得分:0)

尝试intent.getStringExtra("bg");您要保存意图中的数据。当您致电intent.getExtras()时,您将获得该意图的Bundle

final String currentt = getIntent().getString("bg"); 

另请注意,没有理由在字符串对象上调用toString ...

---编辑----

 eventIntent.putExtra("idd", struser.toString());
 eventIntent.putExtra("bg", bg.toString());  

而不是使用您未设置并传递的新Intent i ...