exit

Android - Prevent user from closing app

会有一股神秘感。 提交于 2019-12-20 20:47:09
问题 I've an android application that will be used in a restaurant, so I want that users can't exit from the app. The only thing that users can, is using application. (If possible only admin can exit from app, by logging in or restarting device, I don't know which is the best way). Is there a solution or other way to do this? Thank you very much! 回答1: What you are looking for is a Kiosk mode app, I remember reading that on 4.2 it is possible to write home screen application that in behaviour will

Java's System.exit(0); vs C++ return 0;

亡梦爱人 提交于 2019-12-20 17:39:25
问题 When we learn C++ in school, our professor will tell us to write return 0; at the last line of codes in the main function and it is considered as a good programming practice. In Java, I realise some people writes System.exit(0); at the last line of the main method. However, in C++, if I use exit(0); I get penalized by my professor, because (in school) for procedural programming, we are expected to let the program flow till the end of main and let the program stop naturally. My question : Is

Python run system command and then exit… won't exit

拟墨画扇 提交于 2019-12-20 10:40:56
问题 I have the following python code: os.system("C:/Python27/python.exe C:/GUI/TestGUI.py") sys.exit(0) It runs the command fine, and a window pops up. However, it doesn't exit the first script. It just stays there, and I eventually have to force kill the process. No errors are produced. What's going on? 回答1: instead of os.system use subprocess.Popen this runs a command and doesn't wait for it and then exits: import subprocess import sys subprocess.Popen(["mupdf", "/home/dan/Desktop/Sieve-JFP.pdf

Removing created temp files in unexpected bash exit

一曲冷凌霜 提交于 2019-12-20 07:59:05
问题 I am creating temporary files from a bash script. I am deleting them at the end of the processing, but since the script is running for quite a long time, if I kill it or simply CTRL-C during the run, the temp files are not deleted. Is there a way I can catch those events and clean-up the files before the execution ends? Also, is there some kind of best practice for the naming and location of those temp files? I'm currently not sure between using: TMP1=`mktemp -p /tmp` TMP2=`mktemp -p /tmp` ..

Android app behaving unexpectedly after calling System.exit(0)

 ̄綄美尐妖づ 提交于 2019-12-20 05:40:16
问题 I'm writing a simple app with 4 activities. I'll describe it quickly so you understand what I'm trying to achieve. First activity - MainActivity has some TextEdit fields that collect 2 input parameters - number of reps and length of pause in seconds. A button takes me to the second activity: WorkActivity - all this does is it starts counting until I press 'done' then it either calls PauseActivity, or if it has been the last rep, calls OverviewActivity. PauseActivity counts down the seconds

Will calling System.exit(0); from an object outside of main run garbage collection?

夙愿已清 提交于 2019-12-20 04:56:12
问题 I plan to use an object which is called by my main method to exit the entire program. The object has a method which just runs a System.exit(0). My question is, is this a safe thing to do? If I run System.exit(0) from another object, will garbage collection still clean out the entire program from memory, or will I have issues cleaning the calling class from memory? My thoughts are that either since the JVM will be terminated, the calling class will be garbage-collected, or that I might have

How to exit the program when Ctrl+D is entered in Java?

泄露秘密 提交于 2019-12-20 02:51:02
问题 Below is a section of my Reverse Polish Calculator. If an integer is entered, push it to the stack and, if = is pressed, peek the result. However, I want to add another condition: if CTRL + D is pressed by the user, the program exits. I've had a look online but can't seem to find any solutions. Any ideas? Thanks. Scanner mySc = new Scanner(System.in); //If input is an integer, push onto stack. if (mySc.hasNextInt()) { myStack.push(mySc.nextInt()); } //Else if the input is an operator or an

How do I make an console application run until the user enters “Q”, “q”, “Quit” or “quit” to terminate it?

风格不统一 提交于 2019-12-20 01:34:47
问题 How do I make an console application run until the user enters "Q", "q", "Quit" or "quit" to terminate it? This is my current code: public class Class1 { [STAThread] static void Main(string[] args) { string userName; int i = 0, totalCal = 0, cal = 1; Console.WriteLine("Welcome to the magical calorie counter!"); Console.WriteLine(); Console.Write("Enter in your name -> "); userName = Console.ReadLine(); for (i = 0; i <= 10; i++) { Console.WriteLine("Hello {0}.....Let's add some calories!!",

How to cancel evaluating a required Ruby file?

最后都变了- 提交于 2019-12-19 14:06:28
问题 file1 requires file2 , and I want to be able to cancel evaluating file2 under certain conditions without exiting the whole process. # file1.rb puts "In file 1" require 'file2' puts "Back in file 1" # file2.rb puts "In file 2" # return if some_conditional puts "Still in file 2" When running file1 , the output I want to see is: In file 1 In file 2 Back in file 1 The goal is for Still in file 2 to never print, while Back in file 1 does print. Is there anything I can do in file2 to make this

How to cancel evaluating a required Ruby file?

拥有回忆 提交于 2019-12-19 14:06:03
问题 file1 requires file2 , and I want to be able to cancel evaluating file2 under certain conditions without exiting the whole process. # file1.rb puts "In file 1" require 'file2' puts "Back in file 1" # file2.rb puts "In file 2" # return if some_conditional puts "Still in file 2" When running file1 , the output I want to see is: In file 1 In file 2 Back in file 1 The goal is for Still in file 2 to never print, while Back in file 1 does print. Is there anything I can do in file2 to make this