0

我正在关注Parse 推送通知以将通知推送到我的应用程序,但集成后,我的应用程序没有启动。我在 helloworld 项目中尝试了相同的步骤并且它正在工作,但是在我的项目中,用户应该输入他/她的凭据,然后应用程序应该显示菜单屏幕。

输入凭据后,我尝试将通知推送到菜单屏幕,但菜单屏幕未呈现。这是与显示菜单屏幕的登录按钮相关的代码:

public void loginButtonClickListener(final View view) {
  emailTextBox = (EditText) findViewById(R.id.emailLogin);
  passwordTextBox = (EditText) findViewById(R.id.passwordLogin);
  emailText = emailTextBox.getText().toString().trim();

  SharedPreferences settings = getSharedPreferences("Lisnx", 0);
  SharedPreferences.Editor editor = settings.edit();
  editor.putString("useremail", emailText);
  editor.commit();

  passwordText = passwordTextBox.getText().toString();
  if (emailText == null || emailText.length() == 0) {
    CustomToast.showCustomToast(this, Constants.USER_EMAIL_FIELD_EMPTY_ERROR, Constants.TOAST_VISIBLE_SHORT, layoutInflater);
    emailTextBox.requestFocus();
    return;
  } else if (passwordText == null || passwordText.length() == 0) {
    CustomToast.showCustomToast(this, Constants.PASSWORD_FIELD_EMPTY_ERROR, Constants.TOAST_VISIBLE_SHORT, layoutInflater);
    passwordTextBox.requestFocus();
    return;
  }

  try {
    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
  } catch (Exception e) {}

  pd = ProgressDialog.show(this, null, this.getResources().getString(R.string.authenticateUser), true);
  Thread thread = new Thread(new Runnable() {
    public void run() {
      authenticateUser(view);
    }
  });
  thread.start();
}

这是菜单屏幕的代码。在此我使用代码推送通知:

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.menu);
  layoutInflater = this.getLayoutInflater();
  overridePendingTransition(android.R.anim.slide_in_left,
      android.R.anim.slide_out_right);
  startService(new Intent(this, LocationService.class));
  GridView gridView = (GridView) findViewById(R.id.gridView);
  gridView.setOnItemClickListener(itemClickListener);
  gridView = (GridView) findViewById(R.id.gridView);
  gridView.setAdapter(new ImageAdapter(this));

  peopleNearByIcon = (ImageView) findViewById(R.id.peopleNearByNotification);
  peopleNearByIcon.setOnClickListener(this);
  friendRequestsIcon = (ImageView) findViewById(R.id.friendRequestNotification);
  friendRequestsIcon.setOnClickListener(this);

  nameText = (TextView) findViewById(R.id.userName);
  nameText.setOnClickListener(this);
  userImage = (ImageView) findViewById(R.id.userImage);
  userImage.setOnClickListener(this);

  try {
    runOnUiThread(new Runnable() {
      public void run() {
        GetOtherData getOtherData = new GetOtherData();
        getOtherData.execute();

      }
    });
  } catch (Exception e) {
    e.printStackTrace();
  }

  updateNotificationAndPeopleNearbyCounts();
  updateImageNameStrip();
  Parse.initialize(this, "OFMsL2oQ5vcLVDcPDzzXix7aGvBr9OthzQt9MIjM",
      "cJXRcf818NOrfxRIHGuMv1nl9sU9WXYXNQ6fhbTY");
  ParseAnalytics.trackAppOpened(getIntent());
  /*ParseObject testObject = new ParseObject("TestObject");
    testObject.put("foo", "bar");
    testObject.saveInBackground();*/
  PushService.setDefaultPushCallback(this, MenuActivity.class);
  ParseInstallation.getCurrentInstallation().saveInBackground();

}
4

0 回答 0