Skip to content

Instantly share code, notes, and snippets.

@wightwulf1944
Last active September 3, 2018 13:51
Show Gist options
  • Save wightwulf1944/d4280681f8aba3f3f27e5f9238ae775c to your computer and use it in GitHub Desktop.
Save wightwulf1944/d4280681f8aba3f3f27e5f9238ae775c to your computer and use it in GitHub Desktop.
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());
}
}
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();
}
}
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