|
I wanna create a library for sending notification to my android app but i don't know how it works and what kind of data i should give to the function in the class. this is my code for sending notification but i don't know how to put it in the class for using in another sections of the app. This code works in MainActivity
Intent intent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder b = new NotificationCompat.Builder(context);
b.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher_background)
.setTicker("Hearty365")
.setContentTitle("Default notification")
.setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
.setContentIntent(contentIntent)
.setContentInfo("Info");
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, b.build());
|
|
|
|
|
My simple HttpServlet is called twice everytime I invoke on my endpoint:
http://cdctst1j:15611/TomSampleServlet/TomSampleServletClient
Could you please help me to take a look?
It is very simple.
My files:
1. WEB-INF\classes\TomSampleServletClient.java:
import java.io.IOException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.lang.ClassNotFoundException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public final class TomSampleServletClient extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
xxxx;
xxxx;
}
}
2. WEB-INF\web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>TomSampleServletClient</servlet-name>
<servlet-class>TomSampleServletClient</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TomSampleServletClient</servlet-name>
<url-pattern>/TomSampleServletClient</url-pattern>
</servlet-mapping>
</web-app>
Thanks so much.
|
|
|
|
|
Knowing not much about "servlets", maybe "mapping" something to itself might be something?
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
I am developing a standalone Java application using an embedded Derby database. Can someone help me understand how I could create all the tables of the database should they not exist within the Java code itself?
|
|
|
|
|
Gregory Guy wrote: Can someone help me understand how I could create all the tables of the database An impossible question to answer. You need to com back with a specific detailed question. And if you are not sure how to use Derby, then go to Apache Derby[^].
|
|
|
|
|
What exactly databases do you want?
|
|
|
|
|
I was playing around with annotation processing and was unable to use generated files directly via an import in my code. Instead I had to prepend the generated class with its complete package. I posted a SO question error: package generated.schema does not exist.
In the end I figured out the reason for this, turned out to be pretty simple, see my answer to the same post. Turned out the error was because I was generating the files at last round of processing, instead of anywhere in between.
So my questions are:
How does generating files at last round vs generating files at in between rounds changes accessing the generated files in code?
Is there a specific reason (Java-related or otherwise) for this behavior?
P.S. I posted the question on SO.
|
|
|
|
|
|
And I want a Ferrari and £1,000,000,000.
But it doesn't work like that. "I want" is not a question.
We're more than willing to help those who have tried and got stuck. But nobody here is going to do your work for you.
If you genuinely don't know where to start, then talk to your teacher.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
hey guys i have this code
table.getModel().addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.UPDATE)
{
int column = e.getColumn();
if (column == 2 )
{
pricetext.setText(Integer.toString(calculatesum()));
}
}
textsearch.grabFocus();
textsearch.requestFocus();
}
});
both focus methods arent working and i dont know why , thanks for help
|
|
|
|
|
|
hey thanks for the tip , i meant that both methods fail to set focus on the searchtext field, when i execute the method the cursor is set on the search textfield but then lost again and set into the cell of the table
|
|
|
|
|
Sorry, but it is impossible to guess what may be happening.
[edit]
I have just run a simple test with both methods and they work fine. There must be something else happening in your code.
[/edit]
modified 23-May-19 7:54am.
|
|
|
|
|
|
Hello, Im working on project about algorithme genetic using cloudsim
about bees life algorithme BLA if any one has information or code java about this algorithm please I realy need that me on that I have tried algorithm genetic
|
|
|
|
|
|
Hey guys i have a Jtable shown as : IdP | NameProduct | Quantity | Price |Stock
i have created this method :
public int calculatesum(){
int total=0;
for(int i=0;i<table.getRowCount();i++){
int amount = Integer.parseInt((String)table.getValueAt(i, 2).toString());
int amprice = Integer.parseInt((String)table.getValueAt(i, 3).toString());
total=total+(amount*amprice);
}
return total;
}
that calculates multipilication of (Price*Quantity) and put result in a Jtexfield and called this method in a button action:
private void buttonsearchActionPerformed(java.awt.event.ActionEvent evt) {
conn = DatabaseConnection.dbConnection();
try {
String Sql="select idp,nomp,prix,stock from produit where codep='" + textsearch.getText() + "'";
pst = conn.prepareStatement(Sql);
ResultSet rs = pst.executeQuery();
Object[] columns = {"Id Produit", "Nom Produit", "Quantité", "Prix", "Stock"};
Object[] row = new Object[5];
if (rs.next()){
row[0] = rs.getInt("idp");
row[1] = rs.getString("nomp");
row[2] = 1;
row[3] = rs.getString("prix");
row[4] = rs.getString("stock");
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.addRow(row);}
calculatesum();
pricetext.setText(Integer.toString(calculatesum()));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
My problem is: any changes on quantity won't update the Jtextfield automatically until the button is pressed again. so How can i make the Jtextfield (aka result) changes on the time i change quantity
thanks for help
|
|
|
|
|
|
Thanks for reply ,what do i implement in this methode , isnt there some option to bind jtexfield to table values?
|
|
|
|
|
I don't know, Google for "JTextfield binding" and see what comes up.
|
|
|
|
|
Im working on a programme on cloudsim using java eclisps, its about Genitique algorithme
with algorithme bees life, the question is can any one help me on that please. I have worked on may algorithme like pso, rond robin..
|
|
|
|
|
Member 14239062 wrote: the question is can any one help me on that Yes, we can. As soon as you have a specific question, post it and you shall receive an answer.
If you are looking for people on your team, then this is not the place. We do questions, not projects.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: If you are looking for people on your team
I am thinking that even members of a team would have problems figuring out what that meant.
|
|
|
|
|
jschell wrote: I am thinking If it is thinking, you have arguments. You did not present those.
jschell wrote: even members of a team would have problems figuring out what that meant. Plain English should not be that hard.
Anything else?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|