Display Notification in Android Studio

First we have to make java class named “Utilities”.

Program is—

public class MainActivity extends AppCompatActivity {
    EditText txt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        txt=(EditText)findViewById(R.id.editText);
    }
    public void send(View view){
        try{
            Utilities.SendNotification("" + txt.getText(), this);
        }catch (Exception ex){
            setTitle(ex.getMessage());
        }
    }
    public void cancel(View view){
        try{
            Utilities.CancelNotification(10,this);
        }catch (Exception ex){
            setTitle(ex.getMessage());
        }
    }
}

MainActivity Program—

public class MainActivity extends AppCompatActivity {
    EditText txt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        txt=(EditText)findViewById(R.id.editText);
    }
    public void send(View view){
        try{
            Utilities.SendNotification("" + txt.getText(), this);
        }catch (Exception ex){
            setTitle(ex.getMessage());
        }
    }
    public void cancel(View view){
        try{
            Utilities.CancelNotification(10,this);
        }catch (Exception ex){
            setTitle(ex.getMessage());
        }
    }
}

Leave a Reply