プッシュ通知に GCM を使用している Android アプリケーションを開発しています。MainActivity以下の方法でデバイスを登録しようとしていますonCreate()。
        String regId = GCMRegistrar.getRegistrationId(this);
        if (regId.equals("")) 
        {
        GCMRegistrar.register(this, "My sender id");        
        }
        else
        {
            GCMIntentService.received=true;
        }
        while(!GCMIntentService.received)
        {
            Log.i("RegisterLocation","waiting...... for registartion id");
        }
で登録 ID を取得できませんが、デバイスが登録されると、 のサブクラスである クラスでMainActivity制御がOnRegistered(context,String)機能します。ログにも登録IDを出力できます。GCMIntentServiceGCMBaseIntentService
@Override
protected void onRegistered(Context context, String registrationId) 
{
    received=true;
    Log.i(TAG, "Device registered: regId = " + registrationId);
}
GCM はデバイスの登録に時間がかかるため、デバイスが登録されているかどうかをテストする while ループを記述しました。しかし、そのループは無限ループです。私も試しThread.sleep()ました。その登録IDをローカルサーバーに保存したい。
私の登録IDを取得するための解決策を提案できますMainActivityか?