Far*_*har 5 notifications android android-2.3-gingerbread android-4.2-jelly-bean
我正在尝试在我的应用中显示通知以及其中的进度条.
我的应用规格是我的目标是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());
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,通知显示在通知抽屉中,但没有进度条(在Android 2.2和2.3.3上).但Android 4.1上的进度条显示正常.所以很明显它的兼容性问题.
如何编写带有无限进度条的通知出现在我定位的API上.我试过使用Notification.Builder但是这个类在我目前的规格上不可用.
提前致谢!
-Faraz Azhar