最近在着手研究android framework,在开发消息通知需求时遇到问题,无论是通过android模拟器或者是实体机器均无法推送通知,通知需求是通过主活动中的点击按钮触发消息通知,具体代码如下:
public void onClick(View v) {
switch (v.getId()) {
case R.id.send_notice:
Intent intent = new Intent(this, NotificationActivity.class);
PendingIntent pendingIntent = PendingIntent.
getActivity(this, 0, intent, 0);
NotificationManager manager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.mipmap.ic_png);
Log.d("MainActivity", String.valueOf((bitmap == null)));
Notification notification = new Notification.Builder(this, getString(R.string.app_name))
.setContentTitle("this is a content t