【发布时间】:2012-10-16 11:53:40
【问题描述】:
我正在尝试在我的应用中显示通知以及其中的进度条。
我的应用规范是我的目标是 API 15,最小 SDK 设置为 8。我使用以下代码来显示通知:
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle("My Application")
.setContentText("Downloading...")
.setProgress(0, 0, true)
.setSmallIcon(R.drawable.ic_launcher);
PendingIntent in = PendingIntent.getActivity(getApplicationContext(), 0, getIntent(), 0);
mBuilder.setContentIntent(in);
mNotificationManager.notify(0, mBuilder.build());
使用上面的代码,通知出现在通知抽屉中,但没有进度条(在 Android 2.2 和 2.3.3 上)。但进度条在 Android 4.1 上看起来不错。所以很明显这是一个兼容性问题。
我如何编写代码,让我的通知带有无限的进度条出现在我定位的 API 上。我尝试使用Notification.Builder,但这个类在我当前的规格中不可用。
提前致谢!
-法拉兹·阿扎尔
【问题讨论】:
标签: android notifications android-4.2-jelly-bean android-2.3-gingerbread