jtsamper
28/05/13, 20:36:16
Hola a todos a ver si alguien me puede ayudar.
Estoy generando un Bitmap y este quiero poder usarlo en Notificaciones
NotificationManager NManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Bitmap p2 = writeOnDrawable(R.drawable.transparente, "Hola", "Hola2");
Notification noti = new NotificationCompat.Builder(
getApplicationContext()).setContentTitle("Content Title")
.setContentText("Content Text").setLargeIcon(p2)
.build();
NManager.notify(123, noti);
Esta es la funcion encargada de generar el BITMAP y de introducir los textos que le paso...
public Bitmap writeOnDrawable(int drawableId, String text1, String text2) {
Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId)
.copy(Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setStyle(Style.FILL);
paint.setColor(Color.WHITE);
paint.setTextSize(16);
Canvas canvas = new Canvas(bm);
canvas.drawText(text1, bm.getWidth() / 4, bm.getHeight() / 4, paint);
canvas.drawText(text2, 0, bm.getHeight() / 2 + bm.getHeight() / 4,
paint);
return new BitmapDrawable(getResources(), bm).getBitmap();
}
Con la notificacion anterior no me la muestra, razon ni idea, pero cuando le pongo en el constructor .setSmallIcon(R.drawable.transparente) si me aparece, pero no el personalizado, Salvo que abra las notificaciones...
Un saludo y Gracias
Estoy generando un Bitmap y este quiero poder usarlo en Notificaciones
NotificationManager NManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Bitmap p2 = writeOnDrawable(R.drawable.transparente, "Hola", "Hola2");
Notification noti = new NotificationCompat.Builder(
getApplicationContext()).setContentTitle("Content Title")
.setContentText("Content Text").setLargeIcon(p2)
.build();
NManager.notify(123, noti);
Esta es la funcion encargada de generar el BITMAP y de introducir los textos que le paso...
public Bitmap writeOnDrawable(int drawableId, String text1, String text2) {
Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId)
.copy(Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setStyle(Style.FILL);
paint.setColor(Color.WHITE);
paint.setTextSize(16);
Canvas canvas = new Canvas(bm);
canvas.drawText(text1, bm.getWidth() / 4, bm.getHeight() / 4, paint);
canvas.drawText(text2, 0, bm.getHeight() / 2 + bm.getHeight() / 4,
paint);
return new BitmapDrawable(getResources(), bm).getBitmap();
}
Con la notificacion anterior no me la muestra, razon ni idea, pero cuando le pongo en el constructor .setSmallIcon(R.drawable.transparente) si me aparece, pero no el personalizado, Salvo que abra las notificaciones...
Un saludo y Gracias