我正在关注Parse push notifications 通知我的应用程序,但集成后,我的应用程序无法启动。一世 在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();
}