Git Product home page Git Product logo

notify-android's Introduction

Notify-Android

Release API API

Android library that simplifies creating & showing app notifications. Change the notification's icon or add a circular image or a picture to the notification using the Notify class.

Installation

Add jitpack.io to your root build.gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Include the dependency in your app build.gradle:

dependencies {
    implementation 'com.github.isradeleon:Notify-Android:1.0.5' // updated for Android X
}

Notification channel for API >= 26

You may need to add the default notification channel to your app/res/values/strings.xml file:

<resources>

    <string translatable="false" name="notify_channel_id">MyDefaultChannelID</string>

    <string translatable="false" name="notify_channel_name">MyDefaultChannelName</string>

    <string translatable="false" name="notify_channel_description">MyDefaultChannelDescription</string>

</resources>

Basic usage

@Override
protected void onCreate(Bundle savedInstanceState) {

    Notify.build(getApplicationContext())

        /*
         * Set notification title and content
         * */
        .setTitle("Jill Zhao")
        .setContent("Hi! So I meet you today?")

        /*
         * Set small icon from drawable resource
         * */
        .setSmallIcon(R.drawable.ic_notifications_none_white_24dp)
        .setColor(R.color.colorPrimary)

        /*
         * Set notification large icon from drawable resource or URL
         * (make sure you added INTERNET permission to AndroidManifest.xml)
         * */
        .setLargeIcon("https://images.pexels.com/photos/139829/pexels-photo-139829.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=150&w=440")

        /*
         * Circular large icon
         * */
        .largeCircularIcon()

        /*
         * Add a picture from drawable resource or URL
         * (INTERNET permission needs to be added to AndroidManifest.xml)
         * */
        .setPicture("https://images.pexels.com/photos/1058683/pexels-photo-1058683.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940")

        .show(); // Show notification
}

Methods

Method Description
Notify.build(context) Create a Notify object
setId(id) Set the identifier for the notification
setTitle(title) Set the notification title
setContent(content) Set the notification content
setImportance(importance) Handle the importance with NotifyImportance
setLargeIcon(largeIcon) Set the large icon from a drawable or URL resource
largeCircularIcon() Make large icon circular
setSmallIcon(smallIcon) Set the small icon from a drawable resource
setPicture(picture) Set a picture from a drawable or URL resource
setChannelId(id) Set the notification channel id
setChannelName(name) Set the notification channel name
setChannelDescription(description) Set the notification channel description
setAutoCancel(autoCancel) Set the auto-cancel value
setAction(intent) Set the action for when user clicks the notification
enableVibration(vibration) Enable or disable the vibration
setVibrationPattern(vibrationPattern) Set the vibration pattern
getNotificationBuilder() Return the native NotificationCompat.Builder object
show() Show the notification
cancel(context, id) Cancel the specified notification by id
cancelAll(context) Cancel all notifications

License

This library is licensed under MIT license. View license.

notify-android's People

Contributors

isradeleon avatar mrchanshares avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.