onMessage에서 UI를 업데이트하고 싶습니다.GCMBaseIntentService를 사용하는 Android 푸시 알림
업데이트 진행률 표시 줄 사용, 어떻게 할 수 있습니까? 나단
onMessage에서 UI를 업데이트하고 싶습니다.GCMBaseIntentService를 사용하는 Android 푸시 알림
업데이트 진행률 표시 줄 사용, 어떻게 할 수 있습니까? 나단
는 GCM sample 일을 수행하는 방법을 살펴보십시오. 그것은 주요 활동과 통신 및 GUI 업데이트하려면 다음 방법을 사용
static void displayMessage(Context context, String message) {
Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
intent.putExtra(EXTRA_MESSAGE, message);
context.sendBroadcast(intent);
}
을 그리고 주요 활동의 의도를 잡기 위해 브로드 캐스트 리시버를 사용
private final BroadcastReceiver mHandleMessageReceiver =
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String newMessage = intent.getExtras().getString(EXTRA_MESSAGE);
mDisplay.append(newMessage + "\n");
}
};
그래서 당신이 비슷한을 사용할 수를 메소드를 사용하여 GUI를 갱신하는 기본 활동과 통신하십시오.
알아두면 좋은 답변이 있으며이 코드를 사용하기를 바랍니다. 당신은 활동에 onResume에 넣어서 의도를 얻을 수 있습니다.
는 GCMBaseIntentServiceif(isRunningActivity()){
Intent pushReceivedIntent = new Intent(ACTION_PUSH);
pushReceivedIntent.putExtras(intent.getExtras());
context.sendBroadcast(pushReceivedIntent);
return;
}
의 당신의 onMessage에이 코드를 넣어 당신은 질문이있는 경우, 의견을 넣어 수신기
//register as BroadcastReceiver for Push Action
IntentFilter filter = new IntentFilter();
filter.addAction(NotificationProcessor.ACTION_PUSH);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// put here codes what you want
}
};
registerReceiver(mReceiver, filter);
를 사용하여 해당 의도를받을 수 있습니다. 이게 당신을 도울 수 있기를 바랍니다.
피곤하면 어떨까요? – RobinHood