티스토리 뷰
자신의 스마트폰의 redId를 알려면 처음 애플리케이션을 실행했을 때 나오는 onRegistered를 확인해야 함package kr.priv.android_gcm; import android.app.Activity; import android.os.Bundle; import android.util.Log; import com.google.android.gcm.GCMRegistrar; public class AT_main extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); registGCM(); } private void registGCM() { GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); final String regId = GCMRegistrar.getRegistrationId(this); Log.d("==============1", regId); if ("".equals(regId)) GCMRegistrar.register(this, GCMIntentService.SEND_ID); else Log.d("==============", regId); } }
package kr.priv.android_gcm; import java.util.Iterator; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.Log; import com.google.android.gcm.GCMBaseIntentService; public class GCMIntentService extends GCMBaseIntentService { private static final String tag = "GCMIntentService"; public static final String SEND_ID = "123456789101"; public GCMIntentService() { this(SEND_ID); } public GCMIntentService(String senderId) { super(senderId); } @Override protected void onMessage(Context context, Intent intent) { Bundle b = intent.getExtras(); Iteratoriterator = b.keySet().iterator(); while (iterator.hasNext()) { String key = iterator.next(); String value = b.get(key).toString(); Log.d(tag, "onMessage. " + key + " : " + value); } // Notification } @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); } }
반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- PoolingHttpClientConnectionManager
- insertion
- 스머핑
- Independentsoft
- 선 없이
- call back
- array
- docker
- 443
- Windows 서비스 등록
- Gradle
- react-native
- springboot
- setDoInput
- Stack
- 링크드리스트
- LinkedList
- 안드로이드
- 암호
- 과거 버전 사용
- 빌드 세팅
- java
- Queue
- 정렬
- 젠킨스
- 개발 설정
- elasticsearch
- code push
- sort
- 그라파나
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
글 보관함