FAQ Database Discussion Community


How to close an android application by pressing back key twice?

android,key,back,close
I saw many android applications that if you press the back key once a toast will pop out warning the user that if you press the back key one more time it will close the android application. How can I do that? EDIT: This is different from just closing the...

close and open browser -selenium C# Visual studio

c#,selenium,browser,close
I want to close and then open the browser without close the driver of selenium, using C# I don't want to: driver.Quit(); How Can I close and the open again the browser Chrome?...

How to restart or start process with closing all file descriptors in C

c,restart,close
In C, I want to restart my process clearly. So I tried to call execv(). I seemed works well. However, it keeps sockets and files opened. Is there any way to restart (this) process with closing all file/sockets? Because I don't want to make a zombie process, I don't use...

MySQL Connection | Connection Closure Frequency

c#,mysql,connection,server,close
Yo! So, the whole deal is a server running a bunch of queries on MySQL, most likely simultaneously, varying on the client traffic and request frequency. My question here is: When should the connections be closed? I can think of two scenarios here: I open the connection only once upon...

Python close() not closing [closed]

python,close
Trying to learn the basics of Python and am working on reading from files, opening and closing them. I am able to open the file and read them fine, but I am coming up with issues when trying to close the file. I have been looking on StackOverflow as well...

How to close incoming ssh connection listed through who?

linux,ssh,connection,close
Using command 'who' we can check who is currently logged in to our computer for example as below: [email protected]:~$ who mark :0 2015-04-19 11:14 (:0) mark pts/25 2015-05-13 18:14 (:0) mark pts/24 2015-05-13 18:26 (externalpc_via_ssh) We can see that someone is logged in from other computer named 'externalpc_via_ssh'. Of course...

WPF C# Not Closing Window Correctly - Retains old SQL Data

c#,sql,wpf,close
I got a really strange problem here. I have a WPF application that has multiple windows that it can open. When I run the program (debug from VS 2013), it opens MainWindow.xaml. When I tell MainWindow to open a secondary Window (let's call it Win2.xaml), it opens just fine. I...

Mysqli prepared statements register

php,mysqli,fetch,statements,close
Okay I have one question. I need to check if the user already exists but the question is now what I need to type in the if() I can't fetch because I have closed but if I didn't close i got an error because there can't run 2 statements. So...

Opening and closing forms whilst keeping one permanently open

c#,forms,show,showdialog,close
So I'm wanting to create a program where the basis of the forms will be like so. 1 main form with many different buttons linking to different forms. The main form will never close and will not be able to be, minimized, maximized or resized. All this is fine so...

Should I use Java 7's try-with-resources statement for each line of log

java,java-7,writer,close,try-with-resources
I want to log (append text) into a file every time something happens. I find this might be the correct way to do this with Java 7's try-with-resources statement: public void log(String textLine) { try(PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter("Logfile.txt", true)))) { output.println(textLine); }catch (IOException e) { //exception handling...

How to close the process from class code?

if-statement,axapta,x++,dynamics-ax-2012,close
I call a class form MyForm. In my class I have a if-else statements. I want to close all process, I need a command look-like element.close(); Example, my code: if (_condition a_) { //operations class; } if(_condition b_) { //abort all, and close all; } How should I do if...

overwrite log which is currently in use from shell script

bash,shell,logging,echo,close
I have bash script which redirects all output to the log: /etc/the_watcher.sh &> /tmp/wlog.txt & Inside the script when time is coming I need to clean and overwrite it, without closing. I do it next way: echo "log restarted after sending." > /tmp/wlog.txt After that log really becomes empty, this...

try-with-resource close sequence : FileInputStream close executed three times

java,debugging,java-7,close,try-with-resources
I was trying a simple try-with-resource example using Java 8 on OS X. I see some strange behavior. First, following is the code I am running: public void test() { try( FileInputStream fin = new FileInputStream("/tmp/test"); FileOutputStream fout = new FileOutputStream("/tmp/test1") ){ System.out.println("Nothing here"); System.out.println("Nothing here"); }catch (Exception e) {...

Searching for all open HTML tags and closing them [PHP]

php,html,tags,close
I've got a page on our church website called "The Fridge" which is meant to mimic a fridge where you place sticky notes for information on what's happening in the church. You can see it here: http://www.ypc.org.au/resources/fridge Because sticky notes may be various sizes and have more or less information,...

Close window of another application

.net,window,close
I would like to close a window of an extern application, but only a window, not the whole application. For example, I have the following application (Resource-Manager) with two open windows: Now I would like to close the window "Generate vb-code", but let Resource-Manager open and the application running. Is...

how to fully/correctly exit a Qt program from the main form?

c++,qt,opencv,close
Good evening everybody, Hopefully someone out there can help with this one. I'm writing a Qt program (using Qt 5.4) that reads frames from a webcam based on a QTimer, not a separate thread (interval set to 20 ms, of course it takes much longer than 1/50 of a second...

SFML window.close() does not kill the process when using multithreading

c++,multithreading,process,sfml,close
Below is a test file which essentially performs the same basic task as my actual program. It opens a SFML window, creates some threads, then tries to close them when the window is closed. Unfortunately, when the sfml window is closed, the console window (and the process) continue to run....

Need WPF equivalent of WinForms CloseReason

c#,.net,wpf,application-shutdown,close
I'm looking for the WPF equivalent of WinForm's CloseReason. My app controls a DAQ system that runs 24/7 with some maintenance breaks in between, so it would be nice to know why our app shutdown unexpectedly (due to Windows Updates, power failure, anti-virus, etc.). Back in the WinForm days I...

angularjs accordion dynamically open close

angularjs,dynamic,accordion,close
I am fairly new to Angular js. I want to design a page with angular-bootstrap accordion. I am trying to achieve below functionality, but not sure how. My page has 4 accordion groups. Each group has couple fields. by default, the first accordion group is open only if the user...

close menu when click on li

javascript,jquery,menu,close
I making a single page website and i want when i open my menu and click on a li item, my menu close, so for the moment it is working when i click back on the "menu-burger-wrapper" and i want to set the same thing when i click on items...

C# Application won't close

c#,close
I'm writing a program that uses a char value to determine which string to write. Currently I have (with both cPlant and sSql declared earlier) if (cPlant == 'B') { sSql = "somestring1"; } else if (cPlant == 'D') { sSql = "somestring2"; } else { MessageBox.Show("Error!"); Application.Exit(); MessageBox.Show("Shouldn't see...

How do I close a scanner in java?

java,input,close
When ever I run the following code, private static String input(String Message){ Scanner input_scanner = new Scanner(System.in); System.out.print("\n" + Message); String string = input_scanner.nextLine(); input_scanner.close(); return string; /* * An input function that prints out a message, then accepts an input */ I get this error: Exception in thread "main"...

jquery detect when mouse over tab before closing

jquery,tabs,hover,window,close
I want to display an image on my webpage when the user hovers over the tab top section to close the window. i.e. wait we have special promotion. example can be seen here: http://www.twoj-priz.com/cgi-bin/wingame.pl I tried searching on my own but could'nt find how to do it. Can you kindly...

How to close/kill an android app programmatically without leaving it in the background?

java,android,background,kill,close
When I finish an app using methods like (this.finish()), it always saves it in the background. If I want to close it completely, I have to press the "Recent Apps" button and swipe it out. So my question is how I make it disappear programmatically. After Jim answer I found...

Why is InputStream.close() declared to throw IOException while reading the message?

java,inputstream,java-io,ioexception,close
Recently, I started doing automation, which suggests that I am not properly closing streams. I decide to see if there's anything that can be done with a finally{} block, and then I see, close() can throw IOException. public Iterable<T> convertToMessage(Class<T> messageClazz, MESSAGE_FORMAT messageFormat, File fileToConvert, String duns) throws IOException {...

How to Close all activities without using flag in android

android,android-activity,close
I want to close all activities in a button click without using intent flag Scrren1 Button click --> Screen2 Button click --> Screen3 Button click --> Screen1 --> BackPressed --> Close All activities Any idea about how to achieve this?...

WPF context menu won't fully close before data heavy operation

wpf,contextmenu,dispatcher,close
I have a WPF application where a data-intensive operation is called by a context menu selection. I'm using Dispatcher to run the data-heavy operation in the background, but the context menu does not fully close before it begins - it starts to close (i.e. fade) but doesn't disappear completely before...

How to tell a Ruby program to close itself

ruby,console-application,exit,close
Alright, so I have a pretty simple question: Is there a ruby command to tell the ruby script to close itself? What I am trying to do is this: say I'm running ruby.rb print "What would you like to do next?" next=gets.chomp next.downcase! if next=="close" #this is where i want...

Is it necessary to close scanner object?

java,java.util.scanner,close
I'm a beginner in java, I wanted to know that is it necessary every time to close a scanner object ? If I do not close the Scanner object, it shows "Resource leak : 'input' is never closed". Can anyone help me ? import java.util.Scanner; public class average { public...