0
我试图显示通过我的应用程序发送的通知,但它们不起作用。在我的应用程序中,给定一个条件,必须显示通知。这是我正在使用的方法。该条件被触发后Android中的通知不起作用
public void showNotification(){
NotificationCompat.Builder notificacion = new NotificationCompat.Builder(MapsScreen.this);
notificacion.setTicker("Bicis cerca")
.setContentTitle("Bicis cerca")
.setContentText("Bicis a menos de " + ProfileScreen.getDistance())
.setSound(Uri.parse("android.resource://com.app.sb" + R.raw.bike));
PendingIntent myPendingIntent;
Intent myIntent = new Intent();
Context myContext = getApplicationContext();
myIntent.setClass(myContext, MapsScreen.class);
myPendingIntent = PendingIntent.getActivity(myContext, 0, myIntent, 0);
notificacion.setContentIntent(myPendingIntent);
Notification n = notificacion.build();
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,n);
Log.d("Status", ": entrando");
}
这种方法被称为和mehtod的作品,因为它写在日志中。
非常感谢。