我正在使用
Android Studio.我想添加一些通知的消息.为什么当我运行应用程序时屏幕上没有内容信息?
>
private int i = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void notyfikacja(View view) {
Intent intent = new Intent(this,SecondActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,intent,0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder
.setSmallIcon(android.R.drawable.arrow_up_float)
.setContentInfo("You have"+ ++i + "messages" )
.setContentText("ContentText")
.setContentTitle("ContentTitle")
.setAutoCancel(true)
.setContentIntent(pendingIntent);
Notification notification = builder.build();
NotificationManagerCompat.from(this).notify(0,notification);
}
我加了Notification Screeshot