c2dm사용시 registration_id 값을 못받아 옵니다... 왜 그럴까요???

 

앱 처음에 시작되는 액티비티에 아래처럼 설정했습니다.

//c2dm 서비스를 위해 개별기기의 registration ID를 저장
   SharedPreferences shared_pref = PreferenceManager.getDefaultSharedPreferences(act);
   String regID  = shared_pref.getString("regID", null);
   Log.i("ttt", "appSite regID : " + regID);
  
   if("".equals(regID)) {    
      Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
     intent.putExtra("app", PendingIntent.getBroadcast(act, 0, new Intent(), 0));
     intent.putExtra("sender", "xxx@gmail.com");
     startService(intent);
   }      

 

메니페스트의 리시버 파일 설정은 아래처럼...

 <!-- c2dm으로 부터 고유 ID를 수신할 리시버 클래스 -->
  <receiver android:name="c2dmBroadcastReceiver"   android:permission="com.google.android.c2dm.permission.SEND" >              
      <!-- Receive the actual message -->            
      <intent-filter >                 
          <action android:name="com.google.android.c2dm.intent.RECEIVE"/>                 
          <category android:name="com.myapp.mymsg"/>             
       </intent-filter>             
       <!-- Receive the registration id -->            
       <intent-filter >                 
           <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>                 
           <category android:name="com.myapp.mymsg"/>             
        </intent-filter>         
     </receiver> 

그리고 클래스 파일은,

 public class c2dmBroadcastReceiver extends BroadcastReceiver {
 static String registration_id = null;  
 static String c2dm_msg = null;
 @Override
 public void onReceive(Context context, Intent intent) {
     // TODO Auto-generated method stub
  Log.i("ttt", "start c2dmBroadcastReceiver");

  if(intent.getAction().equals("com.google.android.c2dm.inent.REGISTRATION")) {
   getRegistrationID(context, intent);
  
  } else if(intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
   c2dm_msg = intent.getExtras().getString("subject");  
   Log.i("ttt", "c2dm receve msg : " + c2dm_msg);
   
   Toast.makeText(context, "메시지가 왔습니다!!!", Toast.LENGTH_SHORT).show();   
  }
 }
 
 private void getRegistrationID(Context context, Intent intent) {
  registration_id = intent.getStringExtra("registration_id");
  Log.i("ttt", "registration_id : " + registration_id);
   
        if (intent.getStringExtra("error") != null) {   
            Log.i("ttt", "error : " + intent.getStringExtra("error"));   
        
        } else if (registration_id != null) {
         SharedPreferences shared_pref = PreferenceManager.getDefaultSharedPreferences(context);
         SharedPreferences.Editor editor = shared_pref.edit();
         editor.putString("regID", registration_id);  
         editor.commit();
         
         Log.i("ttt", "recever file regID : " + registration_id);
        }   
    }   

메시지를 보내는 곳에서 regID(registration_id값)을 출력해보면 null 이 나옵니다.

아무래도 리시버 동작이안되는것 같은데 왜 그럴까요???

startService(intent) 부분이 뭔가 안되서 그러는것 같아서 if 문을 제거하고도 해봤는데도 값이 안받아 집니다.

이것 때문에 이틀째 진도가 안나가고 있네요... 꼭 좀 도와주세요.