android消息通知布局,android通知栏消息实例

郑州app开发android通知栏消息。布局代码比较简单,就不介绍了,布局代码只有一个button按钮。

下面是java代码

package cn.xhhkj.videoview;

import androidx.appcompat.app.AppCompatActivity;

import androidx.fragment.app.Fragment;

import androidx.fragment.app.FragmentManager;

import android.animation.AnimatorSet;

import android.animation.ObjectAnimator;

import android.app.FragmentTransaction;

import android.app.Notification;

import android.app.NotificationManager;

import android.app.PendingIntent;

import android.content.Intent;

import android.graphics.drawable.AnimationDrawable;

import android.media.MediaPlayer;

import android.os.Bundle;

import android.util.Log;

import android.view.Menu;

import android.view.View;

import android.view.animation.Animation;

import android.view.animation.AnimationUtils;

import android.view.animation.BounceInterpolator;

import android.view.animation.RotateAnimation;

import android.view.animation.ScaleAnimation;

import android.view.animation.TranslateAnimation;

import android.widget.ArrayAdapter;

import android.widget.AutoCompleteTextView;

import android.widget.ImageButton;

import android.widget.ImageView;

import android.widget.MediaController;

import android.widget.Toast;

import android.widget.VideoView;

public class MainActivity extends AppCompatActivity {

private static final String TAG = "结果是";

private ImageView iv_image;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

public void send(View view) {

Notification.Builder builder= new Notification.Builder(this);

builder.setTicker("通知公告:恭喜您获得最佳。");

builder.setAutoCancel(true);

builder.setContentTitle("通知公告");

builder.setContentText("恭喜您获得最佳。");

builder.setSmallIcon(R.drawable.ic_launcher_foreground);

//        builder.setOngoing(true);

Intent intent2 = new Intent(this,MainActivity.class);

PendingIntent intent3 =PendingIntent.getActivity(getApplicationContext(),1,intent2,PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentIntent(intent3);

Notification notification = builder.getNotification();

NotificationManager mananger = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

mananger.notify(1, notification);

//         mananger.cancel(1);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值