Android的通知:与API的兼容性 [英] Android notifications: compatibility with APIs
问题描述
我想告诉我的应用程序的通知随着它的进度条。
I'm trying to show notifications in my app along with a progress bar in it.
我的应用程序的规格是我,我使用下面的code,显示通知针对15 API以最小的SDK设置为8:
My app specs are that I'm targeting API 15 with minimum SDK set to 8. I'm using the following code to show notifications:
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());
通过上面的code的通知出现在通知抽屉里,但没有进度条(在Android 2.2和2.3.3)。但是,进度条显示正常在Android 4.1。因此,它显然,它的兼容性问题。
With the above code the notifications appear in the notification drawer but no progress bar (on Android 2.2, and 2.3.3). But the progress bar appears fine on Android 4.1. So its obvious that its a compatibility issue.
我如何code,我与一个不确定的进度条通知出现在了我针对的API。我试图用 Notification.Builder
,但这个类是不可用我目前的规格。
How do I code that my notification with an indefinite progress bar appear on the APIs that I'm targeting. I tried using Notification.Builder
but this class is not available on my current specs.
在此先感谢!
-Faraz爱资哈尔
-Faraz Azhar
推荐答案
您是否尝试过使用的 http://developer.android.com/reference/android/widget/RemoteViews.html ?
这篇关于Android的通知:与API的兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!