本文整理汇总了Java中com.xiaomi.mipush.sdk.MiPushMessage类的典型用法代码示例。如果您正苦于以下问题:Java MiPushMessage类的具体用法?Java MiPushMessage怎么用?Java MiPushMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MiPushMessage类属于com.xiaomi.mipush.sdk包,在下文中一共展示了MiPushMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNotificationMessageClicked
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onNotificationMessageClicked(Context context, MiPushMessage message) {
if (SystemUtils.isAppAlive(context, "jk.cloud.app")) {
/*app已经启动*/
Intent mainIntent = new Intent(context, MainActivity.class);
mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent detailIntent = new Intent(context, SystemReportActivity.class);
Intent[] intents = {mainIntent, detailIntent};
context.startActivities(intents);
} else {
/*app已经退出*/
Intent launchIntent = context.getPackageManager().
getLaunchIntentForPackage("jk.cloud.app");
launchIntent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
context.startActivity(launchIntent);
}
}
示例2: onNotificationMessageArrived
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onNotificationMessageArrived(Context context, MiPushMessage message) {
//String log = context.getString(R.string.arrive_notification_message, message.getContent());
//MainActivity.logList.add(0, getSimpleDate() + " " + log);
if (!TextUtils.isEmpty(message.getTopic())) {
mTopic = message.getTopic();
} else if (!TextUtils.isEmpty(message.getAlias())) {
mAlias = message.getAlias();
}
/*Message msg = Message.obtain();
msg.obj = log;
DemoApplication.getHandler().sendMessage(msg);*/
}
示例3: onReceiveMessage
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
public void onReceiveMessage(Context context, MiPushMessage miPushMessage) {
Log4a.i(TAG, "onReceiveMessage -> " + miPushMessage.toString());
String str = (String) miPushMessage.getExtra().get("miui_package_name");
if (str != null && !str.trim().isEmpty()) {
Log4a.d(TAG, "not empty");
Intent intent = new Intent();
intent.setPackage(str);
intent.putExtras(miPushMessage.toBundle());
if (miPushMessage.isNotified()) {
Log4a.d(TAG, "isNotified -> true");
intent.setAction("com.xiaomi.mipush.miui.CLICK_MESSAGE");
context.startService(intent);
return;
}
Log4a.d(TAG, "send broadcast");
intent.setAction("com.xiaomi.mipush.miui.RECEIVE_MESSAGE");
context.sendBroadcast(intent);
}
}
示例4: onReceivePassThroughMessage
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onReceivePassThroughMessage(Context context, MiPushMessage message) {
Log.v(MyApplication.TAG,
"onReceivePassThroughMessage is called. " + message.toString());
String log = context.getString(R.string.recv_passthrough_message, message.getContent());
MainActivity.logList.add(0, getSimpleDate() + " " + log);
if (!TextUtils.isEmpty(message.getTopic())) {
mTopic = message.getTopic();
} else if (!TextUtils.isEmpty(message.getAlias())) {
mAlias = message.getAlias();
}
Message msg = Message.obtain();
msg.obj = log;
MyApplication.getHandler().sendMessage(msg);
}
示例5: onNotificationMessageArrived
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onNotificationMessageArrived(Context context, MiPushMessage message) {
Log.v(MyApplication.TAG,
"onNotificationMessageArrived is called. " + message.toString());
String log = context.getString(R.string.arrive_notification_message, message.getContent());
MainActivity.logList.add(0, getSimpleDate() + " " + log);
if (!TextUtils.isEmpty(message.getTopic())) {
mTopic = message.getTopic();
} else if (!TextUtils.isEmpty(message.getAlias())) {
mAlias = message.getAlias();
}
Message msg = Message.obtain();
msg.obj = log;
MyApplication.getHandler().sendMessage(msg);
}
示例6: onReceivePassThroughMessage
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
/**
* 接收服务器发送的透传消息
*
* @param context
* @param message
*/
@Override
public void onReceivePassThroughMessage(Context context, MiPushMessage message) {
mMessage = message.getContent();
if (!TextUtils.isEmpty(message.getTopic())) {
mTopic = message.getTopic();
} else if (!TextUtils.isEmpty(message.getAlias())) {
mAlias = message.getAlias();
}
// Log.d("TAG", "message:" + mMessage);
intent = new Intent();
chatHelper = new ChatMessageDataHelper(App.getAppContext());
if (mMessage.indexOf("^") != -1 && mMessage.indexOf("@") != -1) {
//user information
userInformation(mMessage);
} else if (mMessage.indexOf("&") != -1 && mMessage.indexOf("@") != -1) {
addFriendInformation(mMessage);
} else {
chatInformation(mMessage);
}
}
示例7: praseMiPushMessage
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
/**
* 解析小米推送接受的消息
*
* @param message
* @return
*/
public static PushMessageBean praseMiPushMessage(MiPushMessage message) {
try {
PushMessageBean pushMessage = new PushMessageBean();
JSONObject jsonObj = new JSONObject(message.getContent());
pushMessage.setTitle(jsonObj.getString("title"));
pushMessage.setMessage(jsonObj.getString("message"));
pushMessage.setType(jsonObj.getString("type"));
pushMessage.setUri(jsonObj.getString("uri"));
pushMessage.setMessageId(message.getMessageId());
return pushMessage;
} catch (Exception e) {
if (BuildConfig.DEBUG)
LogMgr.e(getTag(), "praseMiPushMessage error: " + e.getMessage());
}
return null;
}
示例8: onReceivePassThroughMessage
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onReceivePassThroughMessage(Context context, MiPushMessage message) {
//String log = context.getString(R.string.recv_passthrough_message, message.getContent());
//MainActivity.logList.add(0, getSimpleDate() + " " + log);
if (!TextUtils.isEmpty(message.getTopic())) {
mTopic = message.getTopic();
} else if (!TextUtils.isEmpty(message.getAlias())) {
mAlias = message.getAlias();
}
/*Message msg = Message.obtain();
msg.obj = log;
DemoApplication.getHandler().sendMessage(msg);*/
}
示例9: onReceivePassThroughMessage
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onReceivePassThroughMessage(Context context, MiPushMessage message) {
if (MiPushManager.sMixMessageProvider == null) {
return;
}
String content = message.getContent();
MixPushMessage mixPushMessage = new MixPushMessage();
mixPushMessage.setPlatform(MiPushManager.NAME);
mixPushMessage.setContent(content);
mixPushMessage.setTitle(message.getTitle());
mixPushMessage.setDescription(message.getDescription());
mixPushMessage.setAlias(message.getAlias());
mixPushMessage.setPassThrough(message.getPassThrough());
MiPushManager.sMixMessageProvider.onReceivePassThroughMessage(context, mixPushMessage);
}
示例10: onNotificationMessageClicked
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onNotificationMessageClicked(Context context, MiPushMessage message) {
if (MiPushManager.sMixMessageProvider == null) {
return;
}
String content = message.getContent();
MixPushMessage mixPushMessage = new MixPushMessage();
mixPushMessage.setPlatform(MiPushManager.NAME);
mixPushMessage.setContent(content);
mixPushMessage.setTitle(message.getTitle());
mixPushMessage.setDescription(message.getDescription());
mixPushMessage.setAlias(message.getAlias());
mixPushMessage.setPassThrough(message.getPassThrough());
MiPushManager.sMixMessageProvider.onNotificationMessageClicked(context, mixPushMessage);
}
示例11: onNotificationMessageArrived
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onNotificationMessageArrived(Context context, MiPushMessage message) {
if (MiPushManager.sMixMessageProvider == null) {
return;
}
String content = message.getContent();
MixPushMessage mixPushMessage = new MixPushMessage();
mixPushMessage.setPlatform(MiPushManager.NAME);
mixPushMessage.setContent(content);
mixPushMessage.setTitle(message.getTitle());
mixPushMessage.setDescription(message.getDescription());
mixPushMessage.setAlias(message.getAlias());
mixPushMessage.setPassThrough(message.getPassThrough());
MiPushManager.sMixMessageProvider.onNotificationMessageArrived(context, mixPushMessage);
}
示例12: onReceivePassThroughMessage
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
@Override
public void onReceivePassThroughMessage(Context context, MiPushMessage message) {
String remoteMessageOrign = message.toString();
// Log.d(MYTAG, remoteMessageOrign);
try
{
JSONObject remoteMessage = new JSONObject(message.getContent());
if(!remoteMessage.has("isAt")) remoteMessage.put("isAt","0");
if(!remoteMessage.has("senderType")) remoteMessage.put("senderType","1");
//SharedPreferences Settings = context.getSharedPreferences(PREF, Context.MODE_PRIVATE);
String tokenSender = mySettings.getString("push_type","GCM");
if(tokenSender.equals("MiPush")) {
Log.d(MYTAG, "小米推送:"+remoteMessageOrign);
MessageUtil.MessageUtilDo(context,remoteMessage.getString("msgId"),remoteMessage.getString("type"),remoteMessage.getString("senderType"),remoteMessage.getString("title"),remoteMessage.getString("message"),remoteMessage.getString("isAt"));
}
}
catch (JSONException e)
{
e.printStackTrace();
}
}
示例13: onNotificationMessageArrived
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
public void onNotificationMessageArrived(Context context, MiPushMessage message) {
Helper.showLog(TAG, "onNotificationMessageArrived");
StepCounterUtil.startStepService(context);
if (message != null && !TextUtils.isEmpty(message.getContent())) {
try {
BadgeUtils.setIconBadge(context, 1);
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例14: onNotificationMessageClicked
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
public void onNotificationMessageClicked(Context context, MiPushMessage miPushMessage) {
Helper.showLog(TAG, "onNotificationMessageClicked");
if (miPushMessage != null && !TextUtils.isEmpty(miPushMessage.getContent())) {
try {
handleMessage(context, miPushMessage.getContent().trim());
} catch (JSONException e) {
e.printStackTrace();
}
}
}
示例15: onNotificationMessageClicked
import com.xiaomi.mipush.sdk.MiPushMessage; //导入依赖的package包/类
/**
* 方法用来接收服务器向客户端发送的自定义动作通知消息,
* 这个回调方法会在用户手动点击通知后触发
*/
@Override
public void onNotificationMessageClicked(Context context, MiPushMessage message) {
Log.i("小米消息被点击:", message.toString());
Intent intent = new Intent(JINGOAL_PUSH_ACTION);
intent.putExtra(PUS_CLIENT_TYPE, NXTReceiver.PushClientType.XIAO_MI);
intent.putExtra(MSG_CONTENT, message.getContent());
intent.putExtra(NXTReceiver.MESSAGE_TYPE, NXTReceiver.MessageType.MESSAGE);
context.sendBroadcast(intent);
}