Tengo el siguiente código que estoy usando desde hace una aplicación para Android:crear una notificación persistente y evitar que la notificación en la barra de estado
package com.authorwjf.e_notifications;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Bitmap bm = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.avatar),
getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height),
true);
Intent intent = new Intent(this, Main.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 01, intent, Intent.FLAG_ACTIVITY_CLEAR_TASK);
Notification.Builder builder = new Notification.Builder(getApplicationContext());
builder.setContentTitle("This is the title");
builder.setContentText("This is the text");
builder.setSubText("Some sub text");
builder.setNumber(101);
builder.setContentIntent(pendingIntent);
builder.setTicker("Fancy Notification");
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setLargeIcon(bm);
builder.setAutoCancel(true);
builder.setPriority(0);
Notification notification = builder.build();
NotificationManager notificationManger =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManger.notify(01, notification);
}
}
Básicamente la aplicación cuando lanzó crea una notificación, ahora tengo algunas preguntas:
- Es posible, cuando se inicia la aplicación, que la notificación se muestre en la lista de notificación desplegable pero sin el icono en la barra de estado. es decir. consulte
no puede el icono con un círculo rojo se mostrará? En última instancia, me gustaría crear un servicio que se asiente en la notificación desplegable.
- ¿Hay alguna manera de hacer que la notificación en el menú desplegable persista, es decir. si se presiona el ícono con un círculo en azul (http://imagebin.org/226494) para que la notificación aún permanezca?
Soy nuevo en el desarrollo de Android y estoy tratando de entender lo que puedo hacer con las notificaciones.
Gracias
la imagen las publicaciones no son accesibles. usted podría utilizar imagebin.org – nandeesh
hola, lo siento sobre que he actualizado los enlaces a imagebin – Dino