diff options
author | Alex Khlivnuik <alex.khilvnuik@sonymobile.com> | 2013-01-25 12:50:48 +0100 |
---|---|---|
committer | Henrik Baard <henrik.baard@sonymobile.com> | 2013-02-21 10:38:07 +0100 |
commit | 50e0a1db4e558a062763ed78d9de300cb133ff82 (patch) | |
tree | 29a62fc3c192cb9251e079e9c4b20b7d598440f8 /src/com/android | |
parent | 534cedc2334f2e2ff26a78731289c7f52aa0978b (diff) | |
download | Stk-50e0a1db4e558a062763ed78d9de300cb133ff82.tar.gz |
Stk notifications has purple background
Code was introduced in frameworks/base
96fd7c1c1acc03b40b1813ef65793560c175ef80 that makes notifications
refering to status_bar_latest_event_content.xml directly show up
in purple.
Using internal resource directly is discouraged, or at least the author
bids the user of this directly to have fun with the purple background.
The recommended way is to use the class Notification.Builder (Api 11)
to build your notifications. This commit uses Notification.Builder
class which setup the correct notification layout and background.
Change-Id: Idd850a16b7b68a40726a21947adc58cdcdfa1183
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/stk/StkAppService.java | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java index f729e88..8397173 100644 --- a/src/com/android/stk/StkAppService.java +++ b/src/com/android/stk/StkAppService.java @@ -24,6 +24,8 @@ import android.app.Service; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.os.Handler; @@ -761,33 +763,30 @@ public class StkAppService extends Service implements Runnable { if (msg.text == null) { mNotificationManager.cancel(STK_NOTIFICATION_ID); } else { - Notification notification = new Notification(); - RemoteViews contentView = new RemoteViews( - PACKAGE_NAME, - com.android.internal.R.layout.status_bar_latest_event_content); + PendingIntent pendingIntent = PendingIntent.getService(mContext, 0, + new Intent(mContext, StkAppService.class), 0); - notification.flags |= Notification.FLAG_NO_CLEAR; - notification.icon = com.android.internal.R.drawable.stat_notify_sim_toolkit; + final Notification.Builder notificationBuilder = new Notification.Builder( + StkAppService.this); + notificationBuilder.setContentTitle(""); + notificationBuilder + .setSmallIcon(com.android.internal.R.drawable.stat_notify_sim_toolkit); + notificationBuilder.setContentIntent(pendingIntent); + notificationBuilder.setOngoing(true); // Set text and icon for the status bar and notification body. if (!msg.iconSelfExplanatory) { - notification.tickerText = msg.text; - contentView.setTextViewText(com.android.internal.R.id.text, - msg.text); + notificationBuilder.setContentText(msg.text); } if (msg.icon != null) { - contentView.setImageViewBitmap(com.android.internal.R.id.icon, - msg.icon); + notificationBuilder.setLargeIcon(msg.icon); } else { - contentView - .setImageViewResource( - com.android.internal.R.id.icon, - com.android.internal.R.drawable.stat_notify_sim_toolkit); + Bitmap bitmapIcon = BitmapFactory.decodeResource(StkAppService.this + .getResources().getSystem(), + com.android.internal.R.drawable.stat_notify_sim_toolkit); + notificationBuilder.setLargeIcon(bitmapIcon); } - notification.contentView = contentView; - notification.contentIntent = PendingIntent.getService(mContext, 0, - new Intent(mContext, StkAppService.class), 0); - mNotificationManager.notify(STK_NOTIFICATION_ID, notification); + mNotificationManager.notify(STK_NOTIFICATION_ID, notificationBuilder.build()); } } |