Use Notification DeleteIntent in Android

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

745 Views

This example demonstrate about How to use Notification.deleteIntent 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.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 final static ... Read More

Change Background and Foreground Colors of Tab in Java

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

915 Views

To change the background and foreground colors of tab, use the following methods −JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setBackground(Color.blue); tabbedPane.setForeground(Color.white);Above, we have used the Color class to set the colors for the background and foregroud colors −The following is an example to change the background and foreground colors of tab −package my; import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Devices");       JTabbedPane tabbedPane = new JTabbedPane();       JPanel panel1, panel2, panel3, panel4, panel5;       panel1 = new ... Read More

Set Horizontal Gap Between Elements in GridLayout with Java

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

4K+ Views

Use the setHgap() method to set the horizontal gap between elements in a GridLayout. Let’s say we have a GridLaypout −GridLayout layout = new GridLayout(2, 4);Set the horizontal gap −layout.setHgap(25);The following is an example −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Sections");       JPanel panel = new JPanel();       panel.setBackground(Color.blue);       GridLayout layout = new GridLayout(2, 4);     ... Read More

Limit Characters Returned from a Field in MongoDB Query

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

169 Views

For this, use MongoDB $substr. Let us first create a collection with documents −> dblimitTheNumberOfCharactersDemoinsertOne({"Title":"MongoDB is No SQL database"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf23013b64a577be5a2bc0e") } > dblimitTheNumberOfCharactersDemoinsertOne({"Title":"MySQL is a relational database"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2302db64a577be5a2bc0f") } Following is the query to display all documents from a collection with the help of find() method −> dblimitTheNumberOfCharactersDemofind()pretty();This will produce the following document −{    "_id" : ObjectId("5cf23013b64a577be5a2bc0e"),    "Title" : "MongoDB is No SQL database" } {    "_id" : ObjectId("5cf2302db64a577be5a2bc0f"),    "Title" : "MySQL is a relational database" }Following is the ... Read More

How JavaScript Focus Method Works

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

1K+ Views

focus()Javascript focus() methods helps to highlight a HTML form element. It sets the element as an active element in the current document. In current documentation, focus can be applied to only one single element. The focus can be applied either to a text, a button, etc.  syntaxelement.focus(options);ExampleIn the following example, initially, the text "Tutorialspoint" is in an anchor tag 'a', which as an id called 'focus'. Later on, a function is declared in which the id is called using a DOM method and focus() method is applied on it to change the color of text "Tutorialspoint" to red. Here a button ... Read More

HTML DOM Input URL autofocus Property

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

143 Views

The HTML DOM Input URL autofocus property sets/returns whether Input URL is focused upon initial page load.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputURLObject.autofocusSetting autofocus to booleanValueinputURLObject.autofocus = booleanValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailsTrueIt defines that input will be autofocused on page load.FalseIt is the default value and input is not autofocused.ExampleLet us see an example of Input URL autofocus property − Live Demo Input URL autofocus    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px; ... Read More

Check If an Input is an Integer Using C/C++

Samual Sam
Updated on 30-Jul-2019 22:30:26

4K+ Views

Here we will see how to check whether a given input is integer string or a normal string. The integer string will hold all characters that are in range 0 – 9. The solution is very simple, we will simply go through each characters one by one, and check whether it is numeric or not. If it is numeric, then point to the next, otherwise return false value.Example#include using namespace std; bool isNumeric(string str) {    for (int i = 0; i < str.length(); i++)       if (isdigit(str[i]) == false)       return false; //when one ... Read More

Draw a Line on a JFrame in Java

Samual Sam
Updated on 30-Jul-2019 22:30:26

2K+ Views

The following is an example to draw a line on a JFrame −Examplepackage my; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Line2D; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo extends JFrame {    public SwingDemo() {       JPanel panel = new JPanel();       getContentPane().add(panel);       setSize(550, 300);    }    public void paint(Graphics gp) { super.paint(gp); Graphics2D graphics = (Graphics2D) gp;       Line2D line = new Line2D.Float(200, 150, 150, 220);       graphics.draw(line);    }    public static void main(String[] args) {       SwingDemo demo = new SwingDemo();       demo.setVisible(true);    } }Output

Implement Android Notification Action Without Opening the App

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

1K+ Views

This example demonstrate about How to implement an Android notification action without opening the app.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 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" ... Read More

Set TabLayout Policy to JTabbedPane in Java

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

413 Views

To set TabLayout Policy to JTabbedPane in Java when all the tabs does not fit in a single run, use the method setTabLayoutPolicy() −JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);Above we have set the constant to be SCROLL_TAB_LAYOUT, which is a tab layout policy for providing a subset of available tabs when all the tabs will not fit within a single run.The following is an example −package my; import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Devices");       JTabbedPane tabbedPane = new JTabbedPane(); ... Read More

Advertisements