안녕하세요. GCM 푸시 테스트 중인데요. OnRegistered를 호출 안해서 regId 등록이 안됩니다..
MainActivity 소스이구요
public class MainActivity extends Activity {
public static String device_Id, device_Code, device_Token;
@Override
protected void onCreate(Bundle savedInstanceState) {
startActivity(new Intent(this, SplashActivity.class));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 디바이스 id 얻어오기.
final TelephonyManager tm = (TelephonyManager) getBaseContext()
.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = ""
+ android.provider.Settings.Secure.getString(
getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(),
((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
device_Id = deviceUuid.toString();
// 디바이스 코드 (고정값 GCM)
device_Code = Constant.device_Code;
device_Token = GCMRegistrar.getRegistrationId(this);
Log.d(Constant.TAG, "dvicId : " + device_Id);
Log.d(Constant.TAG, "dvicDsCd : " + device_Code);
Log.d(Constant.TAG, "dvicTkn : " + device_Token);
}
}
Manifest 입니다.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pushtest" >
<!-- GCM requires Android SDK version 2.2 (API level 8) or above. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false"/>
<permission
android:name="com.pushtest.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.pushtest.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- Permisition to geolocation -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".splash.SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar" >
</activity>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.pushtest" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</application>
</manifest>
GCMIntentService OnRegister 부분입니다.
public class GCMIntentService extends GCMBaseIntentService {
public GCMIntentService() {
super(Constant.SENDER_ID);
}
/**
* Method called on device registered
**/
@Override
protected void onRegistered(Context context, String device_Token) {
// TODO Auto-generated method stub
if(!device_Token.equals("") || device_Token != null){
Log.w(TAG, "onRegistered!! " + device_Token);
}
}
뭐가 문제인지 도저히 모르겠네요.. 디버깅에 걸리는것도 아니고 ㅠㅠ
도와주실 수 있나요?