{"id":37161,"date":"2024-11-01T09:55:21","date_gmt":"2024-11-01T09:55:21","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37161"},"modified":"2024-11-01T11:36:24","modified_gmt":"2024-11-01T11:36:24","slug":"java-android-app-development-course-sound-and-vibration-notifications","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37161\/","title":{"rendered":"Java Android App Development Course, Sound and Vibration Notifications"},"content":{"rendered":"<p>Hello! Today, we will learn how to implement a notification feature using sound and vibration in an Android app development course utilizing Java. Notifications that we commonly use are one of the means of conveying important information to users by the app. In this course, we will detail step by step how to send notifications to users utilizing sound and vibration.<\/p>\n<h2>1. Importance of Notifications<\/h2>\n<p>Notifications help users recognize important events occurring in the app. For instance, informing users when an email or message arrives, or when a specific action is completed in the app. Such notifications can attract the user&#8217;s attention not only through visual elements but also through sound and vibration.<\/p>\n<h2>2. Project Setup<\/h2>\n<p>First, you need to create a new Android project. Open Android Studio, select File &gt; New &gt; New Project, and choose Empty Activity. After deciding on the project name and package name and completing the necessary settings, a new project will be created.<\/p>\n<h3>2.1 Gradle Setup<\/h3>\n<p>No special libraries are required to implement notifications, but it is recommended to use the latest Android SDK and Gradle. Open the build.gradle file of the project and verify that it contains the following content.<\/p>\n<pre><code>buildscript {\n    repositories {\n        google()\n        mavenCentral()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:7.1.0'\n    }\n}<\/code><\/pre>\n<pre><code>allprojects {\n    repositories {\n        google()\n        mavenCentral()\n    }\n}<\/code><\/pre>\n<h2>3. Understanding the Concept of Notification<\/h2>\n<p>Notifications are messages that provide important information to users on Android. Starting from Android 8.0 (API level 26), a notification channel must be set up in order to send notifications. The notification channel offers users a way to distinguish between types of notifications. Each channel can control sound, vibration, and priority through user settings.<\/p>\n<h2>4. Code Implementation<\/h2>\n<p>Now let\u2019s get down to implementing notifications including sound and vibration in Android. Below is a detailed code example for creating a notification and setting sound and vibration.<\/p>\n<h3>4.1 Setting Up AndroidManifest.xml<\/h3>\n<p>First, you need to add the necessary permissions in the AndroidManifest.xml file. Add the <code>VIBRATE<\/code> permission to use vibration.<\/p>\n<pre><code>&lt;manifest xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    package=\"com.example.notificationexample\"&gt;\n\n    &lt;uses-permission android:name=\"android.permission.VIBRATE\"\/&gt;\n\n    &lt;application...&gt;\n        ...\n    &lt;\/application&gt;\n&lt;\/manifest&gt;<\/code><\/pre>\n<h3>4.2 Implementing the Main Activity<\/h3>\n<p>Modify the main activity to set it up to receive notifications. Below is the MainActivity.java that includes the code to create notifications.<\/p>\n<pre><code>package com.example.notificationexample;\n\nimport android.app.Notification;\nimport android.app.NotificationChannel;\nimport android.app.NotificationManager;\nimport android.content.Context;\nimport android.media.RingtoneManager;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.os.Vibrator;\nimport android.view.View;\nimport android.widget.Button;\nimport androidx.appcompat.app.AppCompatActivity;\n\npublic class MainActivity extends AppCompatActivity {\n\n    \/\/ Notification Channel ID\n    private static final String CHANNEL_ID = \"exampleChannel\";\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        \n        Button notifyButton = findViewById(R.id.notify_button);\n        notifyButton.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                createNotification();\n            }\n        });\n\n        createNotificationChannel();\n    }\n\n    private void createNotificationChannel() {\n        \/\/ Notification channels are required for Android 8.0 and above\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {\n            CharSequence name = \"Example Channel\";\n            String description = \"Channel for example notifications\";\n            int importance = NotificationManager.IMPORTANCE_HIGH;\n            NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);\n            channel.setDescription(description);\n            NotificationManager notificationManager = getSystemService(NotificationManager.class);\n            notificationManager.createNotificationChannel(channel);\n        }\n    }\n\n    private void createNotification() {\n        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);\n        Notification.Builder builder = new Notification.Builder(this, CHANNEL_ID)\n                .setSmallIcon(R.drawable.ic_notification)\n                .setContentTitle(\"Notification Title\")\n                .setContentText(\"This is a notification with sound and vibration.\")\n                .setAutoCancel(true)\n                .setPriority(Notification.PRIORITY_HIGH)\n                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))\n                .setVibrate(new long[]{0, 1000, 500, 1000});\n\n        notificationManager.notify(1, builder.build());\n\n        \/\/ Activate vibration feature\n        Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);\n        if (vibrator != null) {\n            vibrator.vibrate(1000); \/\/ Vibrate for 1 second\n        }\n    }\n}<\/code><\/pre>\n<h3>4.3 Setting Up the XML Layout File<\/h3>\n<p>Add a button in the activity_main.xml layout file to allow for notification creation.<\/p>\n<pre><code>&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"&gt;\n    \n    &lt;Button\n        android:id=\"@+id\/notify_button\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Send Notification\"\n        android:layout_centerInParent=\"true\"\/&gt;\n\n&lt;\/RelativeLayout&gt;<\/code><\/pre>\n<h2>5. Running and Testing the App<\/h2>\n<p>If all settings are completed, run the app on an emulator or a real device. When you click the &#8220;Send Notification&#8221; button, a notification will appear with sound and vibration. This completes the implementation of a basic notification system. Sound and vibration can be varied by adjusting their respective types and lengths.<\/p>\n<h3>5.1 Additional Notification Settings<\/h3>\n<p>You can freely adjust the title, content, sound, and vibration pattern of notifications to provide notifications that meet user needs. For example, you can create multiple notification channels tailored to various situations and apply different settings to each channel.<\/p>\n<h2>6. Conclusion<\/h2>\n<p>In this course, we learned how to implement a notification feature integrating sound and vibration using Java and Android. Notifications play a crucial role in communication with app users, effectively capturing the user&#8217;s attention through sound and vibration. Now, you too can use this feature to develop more useful Android apps. We look forward to more useful Android development courses in the future!<\/p>\n<p>Thank you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello! Today, we will learn how to implement a notification feature using sound and vibration in an Android app development course utilizing Java. Notifications that we commonly use are one of the means of conveying important information to users by the app. In this course, we will detail step by step how to send notifications &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37161\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Java Android App Development Course, Sound and Vibration Notifications&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[137],"tags":[],"class_list":["post-37161","post","type-post","status-publish","format-standard","hentry","category-java-android-app-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Android App Development Course, Sound and Vibration Notifications - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37161\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Android App Development Course, Sound and Vibration Notifications - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello! Today, we will learn how to implement a notification feature using sound and vibration in an Android app development course utilizing Java. Notifications that we commonly use are one of the means of conveying important information to users by the app. In this course, we will detail step by step how to send notifications &hellip; \ub354 \ubcf4\uae30 &quot;Java Android App Development Course, Sound and Vibration Notifications&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37161\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:55:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:36:24+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37161\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37161\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Java Android App Development Course, Sound and Vibration Notifications\",\"datePublished\":\"2024-11-01T09:55:21+00:00\",\"dateModified\":\"2024-11-01T11:36:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37161\/\"},\"wordCount\":530,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Java Android app development\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37161\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37161\/\",\"name\":\"Java Android App Development Course, Sound and Vibration Notifications - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:55:21+00:00\",\"dateModified\":\"2024-11-01T11:36:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37161\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37161\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37161\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Android App Development Course, Sound and Vibration Notifications\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Android App Development Course, Sound and Vibration Notifications - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/37161\/","og_locale":"ko_KR","og_type":"article","og_title":"Java Android App Development Course, Sound and Vibration Notifications - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello! Today, we will learn how to implement a notification feature using sound and vibration in an Android app development course utilizing Java. Notifications that we commonly use are one of the means of conveying important information to users by the app. In this course, we will detail step by step how to send notifications &hellip; \ub354 \ubcf4\uae30 \"Java Android App Development Course, Sound and Vibration Notifications\"","og_url":"https:\/\/atmokpo.com\/w\/37161\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:55:21+00:00","article_modified_time":"2024-11-01T11:36:24+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37161\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37161\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Java Android App Development Course, Sound and Vibration Notifications","datePublished":"2024-11-01T09:55:21+00:00","dateModified":"2024-11-01T11:36:24+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37161\/"},"wordCount":530,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Java Android app development"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37161\/","url":"https:\/\/atmokpo.com\/w\/37161\/","name":"Java Android App Development Course, Sound and Vibration Notifications - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:55:21+00:00","dateModified":"2024-11-01T11:36:24+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37161\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37161\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37161\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Java Android App Development Course, Sound and Vibration Notifications"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37161"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37161\/revisions"}],"predecessor-version":[{"id":37162,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37161\/revisions\/37162"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}