我想用谷歌雲消息服務來存儲gcm id當用戶登錄到系統,但我不怎麼做登錄activity.Anybody可以幫助我任何工作樣本?谷歌雲消息存儲移動gcm id在登錄活動
0
A
回答
0
可能是你可以按照this鏈接或most prefered from android developers。 這裏有另一個link與關於實施谷歌雲消息的好教程
0
,請使用以下功能:
public static String registerClient(Activity activity) {
String regId = "";
String registrationStatus;
try {
// Check that the device supports GCM (should be in a try/catch)
GCMRegistrar.checkDevice(activity);
// Check the manifest to be sure this app has all the required
// permissions.
GCMRegistrar.checkManifest(activity);
// Get the existing registration id, if it exists.
regId = GCMRegistrar.getRegistrationId(activity);
if (regId.equals("")) {
registrationStatus = "Registering...";
// register this device for this project
GCMRegistrar.register(QwichesApplication.mContext,
CommonVariable.GCM_PROJECTID);
regId = GCMRegistrar.getRegistrationId(activity);
registrationStatus = "Registration Acquired";
Log.d("tag", regId);
// This is actually a dummy function. At this point, one
// would send the registration id, and other identifying
// information to your server, which should save the id
// for use when broadcasting messages.
} else {
registrationStatus = "Already registered";
}
} catch (Exception e) {
e.printStackTrace();
registrationStatus = e.getMessage();
}
Log.d("tag", regId);
// This is part of our CHEAT. For this demo, you'll need to
// capture this registration id so it can be used in our demo web
// service.
return regId;
}
該函數返回gcm_id。 我希望它對你有用...
+0
謝謝dipali ..其實我想連接到web應用程序和存儲gcm id在mysql數據庫變得越來越困難,因爲我是一個非常新的android和gcm以及 – user3377410
+0
我認爲我的代碼對你有幫助。如果它確實有幫助,那麼請接受這個答案。 – dipali
相關問題
- 1. 激活鎖定在谷歌雲消息
- 2. 谷歌雲消息 -
- 3. GCM(谷歌雲消息)在Android的推送通知
- 4. 谷歌端點和谷歌雲消息
- 5. 自動從谷歌雲存儲導入csv到谷歌雲自動
- 6. 谷歌雲存儲
- 7. 活動啓動模式與GCM消息
- 8. 谷歌雲消息傳遞
- 9. 谷歌雲存儲移動應用程序數據庫
- 10. 谷歌雲消息示例
- 11. 谷歌雲消息令牌
- 12. 使用谷歌驅動器作爲谷歌雲存儲
- 13. Android谷歌雲消息傳遞(GCM)和不匹配的發件人ID
- 14. 麻煩保持谷歌雲消息存活
- 15. 谷歌雲消息傳遞(GCM)不能與火狐工作
- 16. 發送谷歌Android雲消息(GCM)是錯誤無效註冊
- 17. 谷歌雲存儲問題
- 18. Android GCM消息活動 - 在活動開始時重新加載
- 19. 通過GCM(谷歌雲消息)爲特定的人定製的消息
- 20. 谷歌pubsub到谷歌雲存儲
- 21. 谷歌收取的數據轉移到谷歌雲存儲
- 22. 谷歌登錄後自動啓動活動 - Android Studio
- 23. 谷歌雲存儲 - java的
- 24. 谷歌雲存儲與gspythonlibrary
- 25. 谷歌雲存儲安裝
- 26. 在Android的谷歌雲消息
- 27. 谷歌雲端點模塊到谷歌雲模塊與GCM?
- 28. 谷歌雲消息如何工作?
- 29. 谷歌雲消息等待註冊
- 30. 谷歌雲消息通知VS數據
感謝andoidgreek – user3377410
你可以接受這個答案作爲有用的,以便其他人可能知道。 – Pankaj