Stylish Progress Bar For Sketchware

Notification Example in 5 steps

To create a Notification in Sketchware, follow the steps given below.

Download sketchware click here.

STEP 1: Create a new project in Sketchware as in the picture.

STEP 2: Now add a button in "main.xml". Change the id of the button as "button". Let the width of the button be "match_parent" and text be "Notification". It should look like this. Add a picture named "image". 

STEP 3: Now select the button and add an "onClick event". Use an add source directly block and copy the code given below. It should look like this.

Notification.Builder mBuilder = new Notification.Builder(MainActivity.this);mBuilder.setSmallIcon(R.drawable.image);mBuilder.setContentTitle("title");mBuilder.setContentText("text");mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(getApplicationContext(),MainActivity.class);PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);

Here the first underlined is the activity in which the notification is created. If you want you can set any activity.

The second underlined is the name of the image that will display in the notification. You have to add an image named "image" to show in the notification.

The third underlined is the title of the notification that is to be displayed and the fourth underlined is the name of the text that is to be displayed. You can edit according to your wish.

The forth underlined is the activity that would open if you click the notification. You can edit according to your wish.

The fifth underlined is whether this notification would cancel after the app closed. You can either True or False.

STEP 5: Now after copying the code save an run the project. The result would show like this.

*Doesn't work on Android 8.0+. Android oreo


This Blog is protected by

Donate Me

Donate Me
Do something Great