첨 질문 드립니다.^^

앱을 개발하면서 GCM푸쉬를 할려구 개발하는데요..

앱을 실행 후 푸시를 하면 노티피케이션으로 잘 받아집니다.

그 후 얼마간의 시간이 지나서 푸시를 하면 노티피케이션 클래스가 생성이 안되요!!



package com.tt;


import java.util.HashMap;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.client.ResponseHandler;

import org.apache.http.util.EntityUtils;


import android.content.Context;

import android.content.Intent;

import android.os.Bundle;

import android.os.Handler;

import android.os.Message;

import android.util.Log;

import android.widget.Toast;


import android.app.Activity;

import android.app.Notification;

import android.app.NotificationManager;

import android.app.PendingIntent;

import android.os.Vibrator;

import android.view.View;


import java.net.*;


import com.google.android.gcm.GCMBaseIntentService;



public class GCMIntentService extends GCMBaseIntentService {

NotificationManager notiM = null;

Notification noti = null;

String gcm_msg = null;

Context mainContext = null;

String receiveMSG = "";

public static String pushStr="";

public static String youid = "";

public static String url = "";

public ServerRequest serverRequest_insert = null;




// GCM에 정상적으로 등록되었을경우 발생하는 메소드


@Override

protected void onRegistered(Context arg0, String arg1) {

Log.d("test", "등록ID:" + arg1);

HashMap<Object, Object> param = new HashMap<Object, Object>();

param.put("regid", arg1);

param.put("mdnNum", MainActivity.mdn);

param.put("muuid",MainActivity.muuid);

Log.d("test", "등록ID 웹에 저장 준비:");

serverRequest_insert = new ServerRequest("http://210....:8080/nasamweb1/gcm/gcm_reg.jsp", param,mResHandler, mHandler);

Log.d("test", "등록ID 웹에 저장 완료:" );

serverRequest_insert.start();

Log.d("test", "등록ID:" + arg1);


}


/**

* 요청후 핸들러에의해 리스트뷰 구성

*/

private Handler mHandler = new Handler() {

public void handleMessage(Message msg) {

serverRequest_insert.interrupt();

String result = msg.getData().getString("result").trim();

if (result.equals("success")) {


Toast.makeText(MainActivity.mContext,

"데이터베이스에 regid가 등록되었습니다."+MainActivity.mdn, 3000).show();

}else if(result.equals("UP")){

Toast.makeText(MainActivity.mContext,

"데이터베이스에 regid가 UPDATE되었습니다."+MainActivity.mdn, 3000).show();

}

else {

Toast.makeText(MainActivity.mContext,

"데이터베이스에 regid 등록이 실패하였습니다."+MainActivity.mdn, 3000).show();

}

}

};




/**


* 요청후 response에 대한 파싱처리


*/


private ResponseHandler<String> mResHandler = new ResponseHandler<String>() {

public String handleResponse(HttpResponse response) throws org.apache.http.client.ClientProtocolException,java.io.IOException {

HttpEntity entity = response.getEntity();

Message message = mHandler.obtainMessage();

Bundle bundle = new Bundle();

String result = EntityUtils.toString(entity).trim();

if (result.equals("success")) {

bundle.putString("result", "success");

} else if(result.equals("UP")){

bundle.putString("result","UP");

}

else {

bundle.putString("result", "fail");

}

message.setData(bundle);

mHandler.sendMessage(message);

return null;

}

};



// GCM에 해지하였을경우 발생하는 메소드


@Override

protected void onUnregistered(Context arg0, String arg1) {

Log.d("test", "해지ID:" + arg1);

}




// GCM이 메시지를 보내왔을때 발생하는 메소드


@Override

protected void onMessage(Context arg0, Intent arg1) {

// TODO Auto-generated method stub

//if (arg1.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {

Log.d("test", "메시지가 왔습니다 : " + arg1.getExtras().getString("test"));


gcm_msg = arg1.getExtras().getString("test");

Log.d("test", "gcm_msg에 저장 : " + gcm_msg);

showMessage();

//}


}




// 오류를 핸들링하는 메소드

@Override

protected void onError(Context arg0, String arg1) {

Log.d("test", "오류 발생 onError == "+arg1);

}




// 서비스 생성자


public GCMIntentService() {

super(MainActivity.PROJECT_ID);

Log.d("test", "GCM서비스 생성자 실행");

}


public void showMessage() {

Thread thread = new Thread(new Runnable() {

public void run() {

handler.sendEmptyMessage(0);

}

});

Log.d("test", "showmessage star");

thread.start();


}


private Handler handler = new Handler() {

public void handleMessage(Message msg) {

Log.d("test", "handleMessage nofiview =호출");

nofiView(gcm_msg);

}

};

private void nofiView(String msg){


Log.d("test", "nofiView =시작");  

    //notiM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

notiM = (NotificationManager)MainActivity.mContext.getSystemService(Activity.NOTIFICATION_SERVICE);

Log.d("test", "notiM =생성");  

    PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.mContext, 0, new Intent(MainActivity.mContext,MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),0);

    Log.d("test", "pendingIntent =생성");  

    Notification notification = new Notification(android.R.drawable.btn_star,"카톡친구찾기", System.currentTimeMillis());

    Log.d("test", "notification =생성");

    notification.flags = Notification.FLAG_AUTO_CANCEL;

    Log.d("test", "notification.flag =설정");

Log.d("test", "nofiView =noti 생성");

   // List에 표시될 항목

try{

String receive = URLDecoder.decode(msg, "utf-8");

//누가 무엇을 했는지 필터링 한다.

int us = receive.indexOf("|");

String receiveStr = receive.substring(0, us); //push 상태

//GCMIntentService.pushStr = receive.substring(us+1); //push 상태

String receive1 = receive.substring(us+1); 

int us2 = receive1.indexOf("|");

//GCMIntentService.youid = receive1.substring(0,us2); //push 요청 ID

String receiver = receive1.substring(0,us2); //push 요청 ID

receiveMSG = receive1.substring(us2+1); //노티피 케이션 메시지

Log.d("test", "push 메시지 받기 ="+receiveMSG);

}catch(Exception e){

Log.d("test", "receiveMSG 에러");

}

Log.d("test", "setLatestEventInfo 이벤트 발생");

notification.setLatestEventInfo(MainActivity.mContext, "카톡친구찾기", receiveMSG, pendingIntent);

Log.d("test", "setLatestEventInfo 이벤트 발생 성공");

notiM.notify(0, notification);

Log.d("test", "notiM 이벤트 발생");

}

}


이렇게 작업을 했는데요...NotificationConfirm 클래스가 푸시 메시지를 받았을때 생성(실행)이 안되면서 에러가 납니다.



이 NotificationConfirm 가 폰 종료나 시간이 지나도 종료되지 않게 하려면 어떻게 해야 하나요?


아 이문제로 한달간 헤딩 중입니다 ㅜ,ㅜ

고수님들 확인좀 부탁해요^^