Last active
September 3, 2018 13:51
-
-
Save wightwulf1944/d4280681f8aba3f3f27e5f9238ae775c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloWorldActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
int notificationId = 0; | |
NotificationManager notificationManager = new NotificationManager(this, notificationId); | |
notificationManager.notify(new HelloWorldNotification()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloWorldNotification implements Notification { | |
@NonNull | |
@Override | |
public android.app.Notification onCreateNotification(Context context) { | |
String notificationChannel = "test"; | |
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, notificationChannel) | |
.setSmallIcon(R.drawable.ic_app) | |
.setContentTitle("HELLO WORLD!"); | |
return builder.build(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. implement Notification | |
2. create a NotifcationManager | |
3. call NotificationManager.notify() giving it an instance of Notification |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment