本文整理汇总了Java中com.google.android.gms.gcm.GoogleCloudMessaging.getMessageType方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleCloudMessaging.getMessageType方法的具体用法?Java GoogleCloudMessaging.getMessageType怎么用?Java GoogleCloudMessaging.getMessageType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.gcm.GoogleCloudMessaging
的用法示例。
在下文中一共展示了GoogleCloudMessaging.getMessageType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(intent);
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
Log.w(TAG, "GCM message...");
if (!TextSecurePreferences.isPushRegistered(context)) {
Log.w(TAG, "Not push registered!");
return;
}
String messageData = intent.getStringExtra("message");
String receiptData = intent.getStringExtra("receipt");
if (!TextUtils.isEmpty(messageData)) handleReceivedMessage(context, messageData);
else if (!TextUtils.isEmpty(receiptData)) handleReceivedMessage(context, receiptData);
else if (intent.hasExtra("notification")) handleReceivedNotification(context);
}
}
示例2: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty() && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
Log.w("GCM", extras.toString());
Intent i = new Intent(this, Main.class);// change the context and activity name.
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED +
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD +
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON +
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
this.startActivity(i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Intent incoming = new Intent("INCOMING");
incoming.putExtra("number", extras.getString("message"));
sendBroadcast(incoming);
}
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
示例3: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) {
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
if (FlowzrSyncEngine.isRunning) {
Log.i(TAG,"sync already in progess");
return;
}
Log.i(TAG,"starting sync from GCM");
new FlowzrSyncTask(getApplicationContext()).execute();
}
}
}
示例4: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
Log.w("PushIntentSerivce", extras.toString());
if (!extras.isEmpty()) {
String from = extras.getString("from");
if (!from.equals("google.com/iid") && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
createNotification(extras);
}
}
PushNotificationBroadcastReceiver.completeWakefulIntent(intent);
}
示例5: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
PDLog.d(GCMIntentService.class, "onHandleIntent");
if (intent == null) {
return;
}
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
Bundle extras = intent.getExtras();
if (!extras.isEmpty() && messageType.equalsIgnoreCase(GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE)) {
handleMessage(intent);
}
GCMBroadcastReceiver.completeWakefulIntent(intent);
}
示例6: onReceive
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(intent);
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
Log.w(TAG, "GCM message...");
if (!TextSecurePreferences.isPushRegistered(context)) {
Log.w(TAG, "Not push registered!");
return;
}
String messageData = intent.getStringExtra("message");
String receiptData = intent.getStringExtra("receipt");
if (!TextUtils.isEmpty(messageData)) handleReceivedMessage(context, messageData);
else if (!TextUtils.isEmpty(receiptData)) handleReceivedMessage(context, receiptData);
}
}
示例7: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Log.i(TAG,"GCM Intent handling ...");
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
Log.i(TAG,extras.getString("force"));
if (!extras.isEmpty()) {
String action=intent.getAction();
if (action.equals("com.google.android.c2dm.intent.RECEIVE")) {
handleMessage(intent);
}
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
if (FlowzrSyncEngine.isRunning) {
Log.i(TAG,"sync already in progress");
return;
}
Log.i(TAG,"starting sync from GCM");
new FlowzrSyncTask(getApplicationContext()).execute();
}
}
}
示例8: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// The getMessageType() intent parameter must be the intent you received
// in your BroadcastReceiver.
String messageType = gcm.getMessageType(intent);
if (extras != null && !extras.isEmpty()) { // has effect of unparcelling Bundle
// Since we're not using two way messaging, this is all we really to check for
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
Logger.getLogger("GCM_RECEIVED").log(Level.INFO, extras.toString());
showToast(extras.getString("message"));
}
}
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
示例9: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) {
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
.equals(messageType)) {
sendNotification("Send error: " + extras.toString());
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
sendNotification("Deleted messages on server: "
+ extras.toString());
} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
.equals(messageType)) {
//When Message is received normally from GCM Cloud Server
sendNotification("" + extras.get(ApplicationConstants.MSG_KEY));
}
}
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
示例10: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) { // has effect of unparcelling Bundle
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
.equals(messageType)) {
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
.equals(messageType)) {
if (MyApp.getInstance().isPushEnabled()) {
sendNotification("Received: " + extras.toString());
}
}
}
WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
示例11: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// The getMessageType() intent parameter must be the intent you received
// in your BroadcastReceiver.
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) { // has effect of unparcelling Bundle
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
// Post notification of received message.
sendNotification(extras);
Logger.i(TAG, "Received: " + extras.toString());
}
}
// Release the wake lock provided by the WakefulBroadcastReceiver.
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
示例12: onReceive
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(intent);
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
Log.d(TAG, "Received message but encountered send error.");
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
Log.d(TAG, "Messages were deleted at the server.");
} else {
// forward this intent to evaluation engine service
intent.setClass(context, EvaluationEngineService.class);
intent.setAction(intent.getStringExtra("action"));
Log.d(TAG, "Forwarding intent to evaluation engine: " + intent);
context.startService(intent);
}
setResultCode(Activity.RESULT_OK);
}
示例13: onReceive
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.i("SERVICES", "Push Recieved");
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String msgType = gcm.getMessageType(intent);
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(msgType)) {
Bundle bundle = intent.getExtras();
if(!bundle.containsKey(ACTION) && nonEmpAction!=null) { //some non EMP push
nonEmpAction.onPushRecived(intent);
return;
}
PushAction action = actions.get(bundle.getString(ACTION));
if(action==null) { //unknown action
Log.i("SERVICES", "Unknown EMP Push");
return;
}
String msgBody = bundle.getString(MSG_BODY);
String msgTitle = bundle.getString(MSG_TITLE);
boolean isAuthReq = action.isAuthRequired();
if(!checkGuid(context,bundle.getString(GCMHelper.GUID))) {
return;
}
if(!isAuthReq ||(isAuthReq && Session.isAuthorized(context))){
action.onPushRecived(intent);
if (!action.isPushNotValid()) {
notifyUser(context, msgTitle, msgBody, action);
}
}
}
}
示例14: onReceive
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) { // has effect of unparcelling Bundle
/*
* Filter messages based on message type. Since it is likely that GCM
* will be extended in the future with new message types, just ignore
* any message types you're not interested in, or that you don't
* recognize.
*/
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
// Is this our message?? Better be if you're going to act on it!
if (MainActivity.PROJECT_NUMBER.equals(extras.getString(EXTRA_SENDER))) {
// Process message and then post a notification of the received message.
String weather = extras.getString(EXTRA_WEATHER);
String location = extras.getString(EXTRA_LOCATION);
String alert = "Heads up: " + weather + " in " + location + "!";
sendNotification(context, alert);
}
Log.i(LOG_TAG, "Received: " + extras.toString());
}
}
}
示例15: onHandleIntent
import com.google.android.gms.gcm.GoogleCloudMessaging; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) {
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
.equals(messageType)) {
sendNotification("Send error: " + extras.toString());
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
sendNotification("Deleted messages on server: "
+ extras.toString());
} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
.equals(messageType)) {
for (int i = 0; i < 3; i++) {
//Log.d(TAG, "Working..." + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime());
//Log.d(TAG, "Working");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
}
//Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
//Log.d(TAG, "Completed work");
sendNotification("Message Received from HyMobi: "
+ extras.get(Commons.GCM_MESSAGE_KEY));
//Log.i(TAG, "Received: " + extras.toString());
//Log.d(TAG, "Received");
}
}
GCMBroadcastReceiver.completeWakefulIntent(intent);
}
开发者ID:mobile-cloud-computing,项目名称:HybridComputationalOffloading,代码行数:39,代码来源:GCMNotificationIntentService.java