本文整理汇总了Java中com.tencent.android.tpush.XGPushTextMessage类的典型用法代码示例。如果您正苦于以下问题:Java XGPushTextMessage类的具体用法?Java XGPushTextMessage怎么用?Java XGPushTextMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XGPushTextMessage类属于com.tencent.android.tpush包,在下文中一共展示了XGPushTextMessage类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTextMessage
import com.tencent.android.tpush.XGPushTextMessage; //导入依赖的package包/类
@Override
public void onTextMessage(Context context, XGPushTextMessage xgPushTextMessage) {
Log.e("收到透传消息", xgPushTextMessage.getContent() + "------" + xgPushTextMessage.getCustomContent() + "---------" + xgPushTextMessage.getTitle());
allMessageOrderListBean=gson.fromJson(xgPushTextMessage.getContent(),AllMessageOrderListBean.class);
SharedPreferences sp=context.getSharedPreferences("data",Context.MODE_PRIVATE);
SharedPreferences.Editor editor=sp.edit();
editor.putString("orderId",allMessageOrderListBean.getOrdersId()+"");
editor.putString("userId",allMessageOrderListBean.getUserId()+"");
editor.commit();
Intent resultIntent = new Intent(context, MainActivity.class);
resultIntent.setAction("CLEAR_NOTI_ACTION");
context.sendBroadcast(resultIntent);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setContentTitle("你有1条消息")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(resultPendingIntent)
.setDefaults(Notification.DEFAULT_ALL)
.setContentText(xgPushTextMessage.getContent().toString());
NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
mNotifyMgr.notify(1, mBuilder.build());
}
示例2: onTextMessage
import com.tencent.android.tpush.XGPushTextMessage; //导入依赖的package包/类
@Override
public void onTextMessage(Context context, XGPushTextMessage message) {
// TODO Auto-generated method stub
String text = "收到消息:" + message.toString();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
try {
JSONObject obj = new JSONObject(customContent);
// key1为前台配置的key
if (!obj.isNull("v5_client")) {
String value = obj.getString("v5_client");
Logger.d(LogTag, "get custom value:" + value);
}
// ...
} catch (JSONException e) {
e.printStackTrace();
}
}
// APP自主处理消息的过程...
Log.d(LogTag, text);
show(context, text);
}
示例3: onTextMessage
import com.tencent.android.tpush.XGPushTextMessage; //导入依赖的package包/类
@Override
public void onTextMessage(Context context, XGPushTextMessage message) {
Log.i(LogTag,"消息透传,,onTextMessage-----");
Toast.makeText(context,"消息透传",Toast.LENGTH_SHORT).show();
String text = "收到消息:title is " + message.getTitle()+",,content is "+message.getContent()+",,customContent is "+message.getCustomContent();
Log.i(LogTag,text);
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
try {
JSONObject obj = new JSONObject(customContent);
// key1为前台配置的key
if (!obj.isNull("repeat_login")) {
String value = obj.getString("repeat_login");
Log.d(LogTag, "get custom value:" + value);
}
// ...
} catch (JSONException e) {
e.printStackTrace();
}
}else {
Log.i(LogTag,"customContent = null || customContent.length() = 0");
}
// APP自主处理消息的过程...
}
示例4: onTextMessage
import com.tencent.android.tpush.XGPushTextMessage; //导入依赖的package包/类
@Override
public void onTextMessage(final Context arg0, final XGPushTextMessage arg1) {
// TODO Auto-generated method stub
ProcessTask task = new ProcessTask();
task.context = arg0;
task.setProcessCheckFinishedListener(new IProcessCheckFinishedListener() {
@Override
public void OnProcessCheckFinished(Boolean result) {
// TODO Auto-generated method stub
if (result){
showNotification(arg0,arg1.getTitle(),arg1.getContent(),arg1.getCustomContent());
return;
}
intent = new Intent();
intent.putExtra(XgAlertActivity.TITLE, "新消息");
intent.putExtra(XgAlertActivity.CONTENT, arg1.getContent());
intent.putExtra(XgAlertActivity.CUSTOMCONTENT, arg1.getCustomContent());
Message message = new Message();
message.what = 1001;
myHandler.sendMessage(message);
}
});
task.execute("");
}
示例5: onTextMessage
import com.tencent.android.tpush.XGPushTextMessage; //导入依赖的package包/类
public void onTextMessage(Context context, XGPushTextMessage message) {
if (context == null || message == null) {
return;
}
String text = "onTextMessage:" + message.toString();
Map<String,Object> map = new HashMap<String,Object>();
map.put("xtype", "message");
map.put("title", message.getTitle());
map.put("content", message.getContent());
JSONObject msg = new JSONObject(map);
JSONObject customObj;
try {
String content =message.getCustomContent();
if(content!=null&&!content.trim().equals("")) {
customObj = new JSONObject(message.getCustomContent());
msg.putOpt("custom", customObj);
}
} catch (JSONException e) {
Log.e(LogTag, "create json falied", e);
}
Log.d(LogTag, text);
if(msgCallbackContext!=null) {
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, msg);
pluginResult.setKeepCallback(true);
msgCallbackContext.sendPluginResult(pluginResult);
}
}
示例6: onTextMessage
import com.tencent.android.tpush.XGPushTextMessage; //导入依赖的package包/类
@Override
public void onTextMessage(Context context, XGPushTextMessage message) {
mDanmakuView = MainActivity.mDanmakuView;
danmushow(message.getTitle().toString()+" : "+message.getContent().toString(),context);
}
示例7: onTextMessage
import com.tencent.android.tpush.XGPushTextMessage; //导入依赖的package包/类
@Override
public void onTextMessage(Context context, XGPushTextMessage xgPushTextMessage) {
}