GCM에서요 제가 Registrationid 를 가져오는건 됐는데....

 

apk파일을 휴대폰에 넣어서 실행하면 설치하고 처음실행했을때는 못가져오고

 

두번째 실행시켰을땐 가져오거든요???

 

그러다가 지우고 또 다시 깔면 처음에 못가져오고 두번째는 또 되고..,,

 

이건 원래 이런건지 아니면 제 소스가 잘못된건지 알려주세요ㅜ

 

public class GCMIntentService extends GCMBaseIntentService {
 private static final String tag = "GCMIntentService";
 public static final String SEND_ID = "510167492403";
 public String c2dm_msg =""; 

 public GCMIntentService(){ this(SEND_ID); }
 
 public GCMIntentService(String senderId) { super(senderId); }

 @Override
 protected void onMessage(Context context, Intent intent) { 
  
  Bundle b = intent.getExtras();
  mMediaPlayer = MediaPlayer.create(this, R.raw.sound1);
  
  

  Iterator<String> iterator = b.keySet().iterator();
  while(iterator.hasNext()) {
   String key = iterator.next();
   String value = b.get(key).toString();
   c2dm_msg = c2dm_msg + value;
   Log.d(tag, "onMessage. "+key+" : "+value);
  }
  c2dm_msg = c2dm_msg.replace("510167492403", "").replace(" ", "").replace("do_not_collapse", "");
  GET_GCM();

 }

 @Override
 protected void onError(Context context, String errorId) {
  Log.d(tag, "onError. errorId : "+errorId);
 }
 

 @Override
 protected void onRegistered(Context context, String regId) {
  Log.d(tag, "onRegistered. regId : "+regId);
 }

 @Override
 protected void onUnregistered(Context context, String regId) {
  Log.d(tag, "onUnregistered. regId : "+regId);
 }

 @Override
 protected boolean onRecoverableError(Context context, String errorId) {
  Log.d(tag, "onRecoverableError. errorId : "+errorId);
  return super.onRecoverableError(context, errorId);
 }


 public void GET_GCM() {
    
     Thread thread = new Thread(new Runnable() {
         public void run() {
        
         handler.sendEmptyMessage(0);
         }
     });
     thread.start();
 }


 private Handler handler = new Handler() {
     public void handleMessage(Message msg) {
                    
         Context context = getApplicationContext();
         int duration = Toast.LENGTH_LONG;
         Toast toast = Toast.makeText(context, c2dm_msg, duration);
         toast.show();
         c2dm_msg = null;


     }
     };


}