Ful*_*ife 4 notifications android
我正在使用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, 0, 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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1138 次 |
| 最近记录: |