Clear Android Notification If Activity Crashes

Anvi Jain
Updated on 30-Jul-2019 22:30:26

242 Views

This example demonstrate about How to clear an Android notification if activity crashesStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Intent ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity {    public static final String NOTIFICATION_CHANNEL_ID = "10001" ;    private ... Read More

Search Documents by Adding Two Properties in MongoDB

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

119 Views

You can use aggregate framework for this. Here, we will get the sum and then match it to search for documents less than a particular number. Let us first create a collection with documents −> db.searchDocumentsDemo.insertOne({"Value1":100, "Value2":560}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3fe1eedc6604c74817ce9") } > db.searchDocumentsDemo.insertOne({"Value1":300, "Value2":150}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3fe29edc6604c74817cea") } > db.searchDocumentsDemo.insertOne({"Value1":400, "Value2":200}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3fe30edc6604c74817ceb") } > db.searchDocumentsDemo.insertOne({"Value1":190, "Value2":210}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3fe45edc6604c74817cec") }Following is the query to display all documents from a collection with the help of ... Read More

Insert Current Date Plus Specific Time in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

453 Views

You can use CONCAT() for this. The syntax is as follows −insert into DemoTable values(concat(curdate(), ' yourSpecificTime’));Let us first create a table −mysql> create table DemoTable    (    ArrivalDate datetime    ); Query OK, 0 rows affected (1.06 sec)Insert some records in the table using insert command. We are adding the current date and time −mysql> insert into DemoTable values(concat(curdate(), ' 10:20:05')); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(concat(curdate(), ' 12:05:00')); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+---------------------+ | ArrivalDate ... Read More

Batch Inserts Using JDBC Statements

Anvi Jain
Updated on 30-Jul-2019 22:30:26

387 Views

Grouping a set of INSERT Statements and executing them at once is known as batch insert.Batch inserts using Statement objectTo execute a batch of insert statements using the Statement object −Add statements to the batch − Prepare the INSERT quires one by one and add them to batch using the addBatch() method of the Statement Interface as shown below −String insert1 = Insert into table_name values(value1, value2, value3, ......); stmt.addBatch(insert1); String insert2 = Insert into table_name values(value1, value2, value3, ......); stmt.addBatch(insert2); String insert3 = Insert into table_name values(value1, value2, value3, ......); stmt.addBatch(insert3);Execute the batch − After adding the required statements, ... Read More

Set 0 for Null Values in MySQL Query

Rama Giri
Updated on 30-Jul-2019 22:30:26

834 Views

For this, you can use IFNULL(). Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Value int    -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values(100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Value) values(140); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Value) values(200); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable(Value) values(450); Query OK, 1 row affected (0.13 ... Read More

C++ Program for Recursive Bubble Sort

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

1K+ Views

In this section we will see another approach of famous bubble sort technique. We have used bubble sort in iterative manner. But here we will see recursive approach of the bubble sort. The recursive bubble sort algorithm is look like this.AlgorithmbubbleRec(arr, n)begin    if n = 1, return    for i in range 1 to n-2, do       if arr[i] > arr[i+1], then          exchange arr[i] and arr[i+1]       end if    done    bubbleRec(arr, n-1) endExample Live Demo#include using namespace std; void recBubble(int arr[], int n){    if (n == 1)     ... Read More

Reservation Protocols in Computer Network

Arushi
Updated on 30-Jul-2019 22:30:26

6K+ Views

Reservation protocols are the class of protocols in which the stations wishing to transmit data broadcast themselves before actual transmission. These protocols operate in the medium access control (MAC) layer and transport layer of the OSI model.In these protocols, there is a contention period prior to transmission. In the contention period, each station broadcasts its desire for transmission. Once each station announces itself, one of them gets the desired network resources based upon any agreed criteria. Since each station has complete knowledge whether every other station wants to transmit or not before actual transmission, all possibilities of collisions are eliminated.Examples ... Read More

Marquee Text in Android Notification

Smita Kapse
Updated on 30-Jul-2019 22:30:26

328 Views

This example demonstrate about How can I marquee the text content in Android Notification.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to res/layout/custom_notification_layout.xml.             Step 4 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.RemoteViews ; public class ... Read More

Query to Retrieve Multiple Items in an Array in MongoDB

Anvi Jain
Updated on 30-Jul-2019 22:30:26

178 Views

To retrieve multiple items in an array, use aggregate framework. Let us first create a collection with documents −> db.retrieveMultipleDemo.insertOne( ...   { ...      "UserDetails": ...      [ ...         { "_id": "101", "UserName":"John", "UserAge": 23 }, ...         { "_id": "102", "UserName":"Carol", "UserAge": 21 }, ...         { "_id": "103", "UserName":"David", "UserAge": 23}, ...         { "_id": "104", "UserName":"Sam", "UserAge": 25} ...      ] ...   } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd40c85edc6604c74817cf0") }Following is the query to ... Read More

Change Cursor in Java Swing

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

2K+ Views

Yes, we can change the default cursor representation in Java. Let us first create a button component −JButton button = new JButton("Button with two borders");Whenever user will keep the mouse cursor on the above button component, the cursor would change to hand cursor −Cursor cursor = button.getCursor(); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));The following is an example to change the cursor −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Cursor; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.border.Border; import javax.swing.border.EtchedBorder; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Demo");   ... Read More

Advertisements