эй все, что я делаю приложение, где пользователь может отправлять gcm-сообщения друг другу приложение работает очень хорошо, и когда я отправляю gcm-сообщение, получатель получает его как уведомление , и когда получатель щелкнет по нему, он откроет домашнюю страницу, но проблема в том, что , когда он нажимает на уведомление, получатель Broadcast не получает его и не вносит изменения в EditText, С другой стороны, если ресивер был используя страницу homepage.class, когда сообщение было получено, оно вносит изменения в EditText (Working) , что может быть проблемой ??? некоторые методы из моего GCMIntentServiceandroid: уведомление ничего не делает
@Override
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, HomePage.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
@Override
protected void onMessage(Context context, Intent intent) {
String message = intent.getExtras().getString("message");
// notifies user
aController.displayMessageOnScreen(context, message);
generateNotification(context, message);
}
void displayMessageOnScreen(Context context, String message) {
Intent intent = new Intent("com.ms.gp.wefamily.DISPLAY_MESSAGE");
intent.putExtra("message", message);
// Send Broadcast to Broadcast receiver with message
context.sendBroadcast(intent);
}
и это код моего BroadcastReceiver
@Override
private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String newMessage = intent.getExtras().getString("message");
// Display message on the screen
Familyname.setText(newMessage);
}
};
пожалуйста, если кто-нибудь знает ответ скажите мне (простите за плохой английский)
вопрос непонятно мне, почему должен быть вызван трансляция трансляции, нажав на уведомление ??? –
также, у вас есть класс под названием Familiyname ??? или он должен быть полем ... –
Семейное имя является объектом EditText и если передатчик не активирован для уведомления , что должно быть? –