连上了不能发消息
终于让客户端和服务端连上啦,但是,当给客户端发通知的时候,客户端就挂了,这是什么情况呀?
终于让客户端和服务端连上啦,但是,当给客户端发通知的时候,客户端就挂了,这是什么情况呀?
2017-06-29
/* notification.setLatestEventInfo(context, title, message,
contentIntent);*/
/*替换setLatestEventInfo()*/
if (Build.VERSION.SDK_INT <16) {
Class clazz = notification.getClass();
try {
Method m2 = clazz.getDeclaredMethod("setLatestEventInfo", Context.class,CharSequence.class,CharSequence.class,PendingIntent.class);
m2.invoke(notification, context, title,
message, contentIntent);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
// mNotification.setLatestEventInfo(mContext, mContentTitle,
// mContentTitle, mContentIntent);
}
else
{
notification = new Notification.Builder(context)
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(contentIntent)
.setSmallIcon(R.mipmap.ic_launcher)
.setWhen(System.currentTimeMillis())
.build();
}
/*end 替换setLatestEventInfo()*/
举报