Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.nickiminaj;
- import androidx.appcompat.app.AppCompatActivity;
- import androidx.core.app.NotificationCompat;
- import androidx.core.app.NotificationManagerCompat;
- import android.app.NotificationChannel;
- import android.app.NotificationManager;
- import android.os.Build;
- import android.os.Bundle;
- import android.view.View;
- import android.view.WindowManager;
- import android.widget.Button;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
- Button btn1 = findViewById(R.id.btn1);
- Button btn2 = findViewById(R.id.btn2);
- btn1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- TextView tv1 = (TextView) findViewById(R.id.tv1);
- tv1.setText("ARMY? delete 💜");
- NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this,CHANNEL_ID)
- .setSmallIcon(R.drawable.nyam)
- .setContentTitle("meow")
- .setContentText("..meow meow .. meow")
- .setPriority(NotificationCompat.PRIORITY_DEFAULT);
- NotificationManagerCompat notificationManager = NotificationManagerCompat.from(MainActivity.this);
- notificationManager.notify(0, builder.build());
- createNotificationChannel();
- }
- });
- btn2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- TextView tv1 = (TextView) findViewById(R.id.tv1);
- tv1.setText("ARMY? no delete 💜");
- NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this,CHANNEL_ID)
- .setSmallIcon(R.drawable.nyam)
- .setContentTitle("RRRRrrrrr")
- .setContentText("..arrf arf .. arrrrffff")
- .setPriority(NotificationCompat.PRIORITY_DEFAULT);
- NotificationManagerCompat notificationManager = NotificationManagerCompat.from(MainActivity.this);
- notificationManager.notify(0, builder.build());
- createNotificationChannel();
- }
- });
- }
- public static final String CHANNEL_ID = "mychannel";
- NotificationChannel channel;
- private void createNotificationChannel(){
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
- int importance = NotificationManager.IMPORTANCE_DEFAULT;
- channel = new NotificationChannel(CHANNEL_ID, "mynotif", importance);
- channel.setDescription("channel");
- NotificationManager notificationManager = getSystemService(NotificationManager.class);
- notificationManager.createNotificationChannel(channel);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement