현재 앱이 꺼져있을때 노티가와서 PendingIntent를 이용해 노티를 클릭시 메인화면을 띄우고 다이얼로그를 띄울 수 있는상태인데요
앱이 켜있는상태에서는 노티를 보내지않고 바로 다이얼로그를 띄우고싶은데 현재 떠있는 화면에 다이얼로그를 띄우는방법이 궁금합니다
컨텍스트를이용해 다이얼로그를 띄우려했었는데 서비스 안에서 getApplicationContext를 한다고해서 현재 떠있는 화면의 컨텍스를 받아오는것이 아니라 다이얼로그를 띄우기가 힘드네여
두번쨰 방법으로 Theme를 다이얼로그로한 액티비티를 띄우는데 현재화면이 아닌 런처 화면에서 다이얼로그가 띄어집니다
혹시 해결방법좀 알려주시면 감사하겠습니다 ㅜㅜ
GCM에서 저와 같은 문제질문입니다
http://www.androidside.com/bbs/board.php?bo_table=b49&wr_id=124364
소스코드
private void sendNotification(NotiApplyItem item) {
boolean isOpen; //앱이 포그라운드 상태인지
isOpen = isAppOpened();
if (isOpen == true) {
Intent intent = new Intent(this, PopupApplyActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
// intent.putExtras(bun);
PendingIntent pie= PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
try {
pie.send();
} catch (PendingIntent.CanceledException e) {
}
} else {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("notiItem", item);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(item.getMessage())
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
// Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
// vibrator.vibrate(1000);
// 잠든 단말을 깨워라.
PushWakeLock.acquireCpuWakeLock(this);
TimerTask task = new TimerTask() {
@Override
public void run() {
PushWakeLock.releaseCpuLock();
}
};
Timer timer = new Timer();
timer.schedule(task, 500);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, notificationBuilder.build());
}
}