Start an Activity from a Notification in Android

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

1K+ Views

This example demonstrate about Start an Activity from a Notification in AndroidStep 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.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity {    public static final String ... Read More

Difference Between && and & Operators in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

207 Views

The difference between '==' and '===' is that former checks only value but the latter checks value and also data type(String, Boolean etc).The following example gives whether values assigned are equal or not irrespective of datatype. a) "==" operator(checks equality) Example Live Demo    var x = 5;    var y = 5;    var z = 6;    document.getElementById("strict").innerHTML =    (x == y) + "" + (x == z); Outputtrue falseb) '===' operator (Checks strict equality)     "==="  operator gives true if and only if both value and data type are equal.If not it returns false.In ... Read More

Find Number of Ways to Write a Number as Sum of Smaller Numbers in C++

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

269 Views

In this program we will count the number of ways one number can be represented by sum of numbers smaller than itself. This program will count the partition of given numbers. We take a number n as input, then starting from a number break it by removing 1 at a time. If the new partition is generated, increase the counter.AlgorithmpartitionCount(n)Input : The number nOutput : The number of partitionsBegin    Create array p of size n    k := 0    count := -1    put n as the first element of array p    Repeat the following steps, do ... Read More

Perform SELECT Using COUNT in MySQL

George John
Updated on 30-Jul-2019 22:30:26

211 Views

To perform SELECT with COUNT, use aggregate function COUNT(). Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(100),    Subject varchar(100)    ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Subject) values('John', 'MySQL'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name, Subject) values('John', 'Java'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name, Subject) values('Carol', 'MongoDB'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name, Subject) values('Carol', ... Read More

Difference Between Files Written in Binary and Text Mode in C++

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

676 Views

Text modeBinary modeIn text mode various character translations are performed i.e;“\r+\f” is converted into “”In binary mode, such translations are not performed.To write in the files:ofstream ofs (“file.txt”);Orofstream ofs;ofs.open(“file.txt”);to write in the files: ofstream ofs(“file.txt”, ios::binary);orofstream ofs;ofs.open(“file.txt”, ios::binary);To add text at the end of the file:Ofstream ofs(“file.txt”, ios::app);orofstream ofs;ofs.open(“file.txt”, ios::app);To add text at the end of the file:Ofstreamofs(“file.txt”, ios::app|ios::binary);or ofstream ofs;ofs.open(“file.txt”, ios::app|ios::binary);To read files:ifstream in (“file.txt”);orifstreamin ; in.open(“file.txt”);To read files: ifstream in (“file.txt”, ios::binary);orifstream in ;in.open(“file.txt”, ios::binary);Read More

HTML DOM Input Image Object

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

250 Views

The HTML DOM input image Object represent the element with type=”image” of an HTML document.Let’s see how to create input image object −SyntaxFollowing is the syntax −var imageInput = document.createElement(“INPUT”); imageInput.setAttribute(“type”, ”image”);PropertiesFollowing are the properties of HTML DOM input image Object −PropertyExplanationAltIt returns and modify the value of the alt attribute of an input image.AutofocusIt returns whether the browser finished loading an image in HTML web page or not.defaultValueIt returns and modify the default value of an input image.DisabledIt returns and modify the value of the disabled attribute of an input image.FormIt returns the reference of the form that ... Read More

Product Array Puzzle (O(1) Space) in C++

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

215 Views

Here we will see one interesting problem related to array. There is an array with n elements. We have to create another array of n elements. But the i-th position of second array will hold the product of all elements of the first array except the i-th element. And one constraint is that we cannot use the division operator in this problem. We have to solve this problem in-place without using any additional spaces.If we can use the division, operation, we can easily solve this problem, by getting the product of all elements, then divide i-th element of first array ... Read More

Print N Terms of Newman Conway Sequence

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

434 Views

Newman-Conway Sequence is used for generating following integer sequence.1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12Formula used for generating Newman-Conway sequence for n numbers is −P(n) = P(P(n - 1)) + P(n - P(n - 1)) Where, p(1) =p(2) =1AlgorithmSTART Step 1 -> Input variable n(e.g. 20) Step 2 -> start variables as i, p[n+1], p[1]=1, p[2]=1 Step 3 -> Loop For i=3 and i End Loop For STOPExample#include int main() {    int n = 20,i;    int p[n + 1];    p[1] = 1;    p[2] = 1;    printf("Newman-Conway Sequence is :");    printf("%d %d ",p[1],p[2]);    for (i = 3; i

Check for Existing Document in MongoDB

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

158 Views

You can use findOne() for this. Following is the syntax −db.yourCollectionName.findOne({yourFieldName: 'yourValue'});Let us create a collection with documents −> db.checkExistingDemo.insertOne({"StudentName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbdf90dac184d684e3fa265") } > db.checkExistingDemo.insertOne({"StudentName":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbdf912ac184d684e3fa266") } > db.checkExistingDemo.insertOne({"StudentName":"Sam"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbdf916ac184d684e3fa267") } > db.checkExistingDemo.insertOne({"StudentName":"Mike"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbdf91bac184d684e3fa268") }Display all documents from a collection with the help of find() method −> db.checkExistingDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cbdf90dac184d684e3fa265"), "StudentName" : "John" } { "_id" : ObjectId("5cbdf912ac184d684e3fa266"), "StudentName" : "Carol" } ... Read More

Create JCheckBox from Text in Swing

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

209 Views

The following is an example to create JCheckBox from text in Swing:Exampleimport java.awt.FlowLayout; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo {    public static void main(String[] args) {       JCheckBox checkBox1 = new JCheckBox("Cricket");       JCheckBox checkBox2 = new JCheckBox("Squash");       JCheckBox checkBox3 = new JCheckBox("Football");       checkBox3.setSelected(true);       JCheckBox checkBox4 = new JCheckBox("Hockey");       JCheckBox checkBox5 = new JCheckBox("Fencing");       JCheckBox checkBox6 = new JCheckBox("Tennis");       JFrame frame = new JFrame();       frame.setLayout(new FlowLayout());       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   ... Read More

Advertisements