标签: android-notification-bar

在没有弹出的情况下创建通知

我正在尝试向android 3中的"托盘"添加一个android通知,但我不希望每次调用notify()时它都会"弹出".

我设法通过在通知上设置FLAG_ONLY_ALERT_ONCE标志来做到这一点,但是当我第一次设置它时它仍然会发出警报.

看起来这是可能的,但我不知道如何做到这一点(一个例子是华硕变压器的Prime ROM.当你插入扩展坞时,一个新的持续通知将被添加到通知区域,但那里没有警报,或"弹出"那里..它只是静静地在列表中添加另一个图标.我怎么能这样做?

android android-notifications android-notification-bar

6
推荐指数
1
解决办法
981
查看次数

Android相当于IOS的networkActivityIndi​​catorVisible?

如何在Android的状态栏上显示网络指示器?networkActivityIndicatorVisibleAndroid中的IOS相当于什么?或者如果没有,我如何在Android中创建类似的网络指示器?

android ios android-notification-bar

6
推荐指数
0
解决办法
368
查看次数

如何在状态栏中显示通知?

所以我在我的活动中创建了这个通知

Notification n = new Notification.Builder(getApplicationContext())
    .setContentTitle("New mail from " + sender)
    .setContentText(subject)
    .setSmallIcon(R.drawable.notification)
    .build();
Run Code Online (Sandbox Code Playgroud)

我现在如何在状态/通知栏中显示声音?

android android-notification-bar

6
推荐指数
1
解决办法
1万
查看次数

更新通知时NotificationCompat代码文本不显示

背景

这是我正在编写的一个应用程序,用于熟悉一些API,除了在Android中演示某些功能之外,它没有任何实际用途.我有一个Service在前台(startForeground)中运行,并且正在进行中Notification,当点击返回到应用程序时.的Service的广播,并记录它们的DB监听.

启动服务,创建通知

创建我的Notification使用NotificationCompat.BuilderonCreateService:

@Override
public void onCreate() {
    super.onCreate();
    Log.v(TAG, "onCreate");

    // Get the notification manager to update notifications
    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    Intent openAppIntent = new Intent(this, MainActivity.class);
    openAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent selectNotifPendingIntent = PendingIntent.getActivity(this, 0, openAppIntent, 0);

    // Build the notification to show
    mNotificationBuilder = new NotificationCompat.Builder(this)
    .setContentTitle("Monitor Service")
    .setContentText("Logging system events")
    .setTicker("Starting monitor service")
    .setSmallIcon(R.drawable.ic_stat_cloud)
    .setContentIntent(selectNotifPendingIntent)
    .setOnlyAlertOnce(false)
    .setPriority(NotificationCompat.PRIORITY_LOW) …
Run Code Online (Sandbox Code Playgroud)

android android-notifications android-notification-bar android-2.3-gingerbread

6
推荐指数
0
解决办法
7568
查看次数

Android模拟器只会打开一次通知栏

我看到了这种奇怪的行为.我只能在模拟器上打开一次通知栏.

在Macbook pro/OSX 10.8上运行具有480x800屏幕的API级别17(具有API级别17设置的Nexus One)

有经验的人有什

android 4.2.2模拟器中的状态栏相同

在4.2模拟器中报告为Notification栏无效的错误

android android-emulator android-notification-bar

6
推荐指数
1
解决办法
1204
查看次数

Android:如何区分CLEAR所有事件与通知栏和用户操作

根据规范,.setDeleteIntent(pendingIntent)与两个动作相关联(CLEAR来自通知栏的所有事件和用户动作,如滑动).

我的要求是当用户触摸通知栏上显示的通知时,必须将其转发到NotificationsList.class.这是通过我的pendingInent完成的:

PendingIntent sendPendingIntent = PendingIntent.getActivity(context, reminderId, new Intent(context, NotificationsList.class), PendingIntent.FLAG_UPDATE_CURRENT);
Run Code Online (Sandbox Code Playgroud)

但是,单击CLEAR按钮时,用户根本不能导航到应用程序.随着.setDeleteIntent(pendingIndent)我无法满足第二个要求.用户仍然导航到NotificationsList.class.

有没有办法以编程方式区分CLEAR从CLEAR按钮触发的所有通知事件与用户操作(如触摸或滑动通知栏上的特定通知)?

notifications android clear android-notification-bar

6
推荐指数
1
解决办法
615
查看次数

如何在android中添加动态图像而不是通知图标?

我使用下面的代码在通知栏中显示通知。

效果很好。

但我需要动态显示来自网络服务的通知图标。

我该怎么办?

NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Notification note = new Notification(R.drawable.image,"status message", System.currentTimeMillis());

        Intent in = new Intent(Notify.this,CommentU.class);
        PendingIntent pi = PendingIntent.getActivity(Notify.this, 0, in, 0);
        note.setLatestEventInfo(Notify.this,"NotificationTitle", "You have a new Commentio", pi);
        note.number = ++count;
        note.vibrate = new long[] { 500l, 200l, 200l, 500l };
        note.flags |= Notification.FLAG_AUTO_CANCEL;
        nm.notify(NOTIFY_ME_ID, note);
Run Code Online (Sandbox Code Playgroud)

提前致谢。

android android-notification-bar

5
推荐指数
1
解决办法
7163
查看次数

是否可以减少在 Android 中显示的通知时间?

我正在使用波纹管代码在我的 Android 手机上显示通知。我想减少用于显示通知的时间。现在,它花费大约 2 秒的时间来显示,然后它被隐藏。我想将时间从 2 秒减少到 1 秒。是否可以?

Notification notification = new NotificationCompat.Builder(context)
                    .setContentTitle(context.getString(R.string.app_name))
                    .setContentText("Notification")
                    .setAutoCancel(false)
                    .setPriority(Notification.PRIORITY_MAX)
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
                    .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
                    .build();

NotificationManager notificationManager = getNotificationManager(context);
notificationManager.notify(SAFER_DISCONNECTED_NOTIFICATION_ID, notification);
Run Code Online (Sandbox Code Playgroud)

android android-notifications android-notification-bar

5
推荐指数
1
解决办法
1317
查看次数

单击通知时如何打开活动

我需要使用带有单击事件的通知,我有通知方法,但此方法不会打开我的活动。

我的代码:

 private void sendNotification(String msg) {

        NotificationCompat.Builder mBuilder =  new NotificationCompat.Builder(this)
        .setContentTitle("EXX")
        .setSmallIcon(R.drawable.ic_launcher)
        .setStyle(new NotificationCompat.BigTextStyle()
        .bigText(msg))
        .setContentText(msg)          
        .setOngoing(true);          
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}    
Run Code Online (Sandbox Code Playgroud)

这可能吗,

谢谢。

java android android-notifications android-notification-bar

5
推荐指数
2
解决办法
1万
查看次数

如何在 NotificationCompat.Builder.setLargeIcon() 中加载 Glide 缓存图像?

像这张图片一样,我正在尝试将通知大图标设置为用户个人资料缩略图,例如 whatsapp 或其他聊天应用程序

我试过了

 Glide.with(context)
            .asBitmap()
            .load(messageNotification.getLargeIcon())
            .into(new SimpleTarget<Bitmap>() {
                @Override
                public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
                   builder.setLargeIcon(resource);

                }
            });
Run Code Online (Sandbox Code Playgroud)

但它不起作用..有帮助吗?

android push-notification android-notification-bar android-glide

5
推荐指数
1
解决办法
2073
查看次数