EncoreLaw 2016-11-01 15:54 采纳率: 46.2%
浏览 4145
已结题

android很小的问题为什么notification设置了setTicker也不会在通知栏出现?

 package com.example.notificationtest;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_layout);
        Button sendNotice = (Button) findViewById(R.id.send_notice);
        sendNotice.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                PendingIntent pendindIntent = PendingIntent.getActivity(
                        MainActivity.this, 0, new Intent(MainActivity.this,
                                Notification.class), PendingIntent.FLAG_CANCEL_CURRENT);
                Notification notification = new Notification.Builder(
                        MainActivity.this).setSmallIcon(R.drawable.ic_launcher)
                        .setTicker("it's  ticker text" )
                        .setContentTitle("content title")
                        .setContentText("content text")
                        .setContentIntent(pendindIntent).build();
                notification.flags |= Notification.FLAG_AUTO_CANCEL;
                manager.notify(1, notification);
            }
        });
    }
}

为什么我的notification设置了setTicker("it's ticker text" )也不会在status bar出现??

  • 写回答

1条回答 默认 最新

  • devmiao 2016-11-01 15:55
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题