我在嘗試實現推送通知客戶端。我想在onMessage(Context arg0,Intent arg1)函數中顯示Toast。在GCMBaseIntentService中顯示祝酒
,這是我的代碼:
public class GCMIntentService extends GCMBaseIntentService {
static Context c;
@SuppressWarnings("hiding")
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super("717816998404");
c = this.getBaseContext();
}
/**
* Issues a notification to inform the user that server has sent a message.
*/
@Override
protected void onError(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
protected void onMessage(Context arg0, Intent arg1) {
Log.d("GCM", "RECIEVED A MESSAGE");
Log.d("GCM", "RECIEVED A MESSAGE");
Log.d("GCM", "RECIEVED A MESSAGE");
Log.d("GCM", "RECIEVED A MESSAGE");
Log.d("GCM", "RECIEVED A MESSAGE");
Log.d("GCM", "RECIEVED A MESSAGE");
Log.d("GCM", "RECIEVED A MESSAGE");
String str =arg1.getExtras().getString("PVAL");
Log.i("PVAL",str);
// I want to display a toast here
}
@Override
protected void onRegistered(Context arg0, String arg1) {
// TODO Auto-generated method stub
Log.i("TEST", arg1);
Log.e("TEST", arg1);
}
@Override
protected void onUnregistered(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
}
我想知道如何顯示接收到的消息,我想dispaly舉杯檢查消息。
例子是創造新的意圖,但不允許與當前打開的意圖是什麼想法做的問題? – user170317 2012-10-19 16:00:30