我需要Google雲消息示例應用程序。用示例服務器來測試我的應用程序。誰可以幫我這個事?Google Cloud messaging - 示例服務器
我需要一個樣本服務器來測試我的代碼,我已經編寫了代碼,但我不知道它是否會工作。我不知道服務器端編碼,所以任何人都可以幫助我。這裏是我的代碼
意圖服務
package com.example.pushnotificationsample;
import android.content.Context;
public class GCMIntentService extends GCMBaseIntentService {
protected GCMIntentService(String senderId) {
super(senderId);
// TODO Auto-generated constructor stub
}
@Override
protected void onError(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
protected void onMessage(Context arg0, Intent msgIntent) {
// TODO Auto-generated method stub
Log.d("GCM", "RECIEVED A MESSAGE");
// String msg=msgIntent.getStringExtra("Message");
Log.d("GCM", msgIntent.toString());
// Get the data from intent and send to notificaion bar
}
@Override
protected void onRegistered(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
protected void onUnregistered(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
}
我的主要活動
package com.example.pushnotificationsample;
import android.app.Activity;
import com.google.android.gcm.GCMRegistrar;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(this);
// GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
GCMRegistrar.register(this, "555817657362");
Log.v("Msg", "registered");
} else {
Log.v("Msg", "Already registered");
}
}
}
親愛的,如果你已經下載了「從SDK管理器GCM包」,那麼有客戶端,服務器的樣本。只需檢查** android-sdk/extras/google/GCM **目錄 – 2012-07-13 04:46:27
Tnx很多Paresh – Dinu 2012-07-13 05:24:36
@PareshMayani http://chat.stackoverflow.com/transcript/message/4508859#4508859但無法在sdk manager中找到extras文件夾 – Khan 2012-07-13 05:36:45