Java Splash Screen Application - java

I am running into an issue where it takes a really long time (10 seconds or so) to get through my ANT setup and running my java application. This will delay the splash screen for the jvm by at least 10 seconds to show up. Unfortunately, I can not move away from ANT to start the application due to certain constraints. What I would like to be able to do, and was wondering if anyone had a better solution, is to create a small splash screen application that would have the splash screen as an argument to the JVM so it will show up quickly and then use Runtime.getRuntime().exec("wscript....) to launch the other application. My concern is how to kill off the first application.
What I was thinking of doing is using jps within the other application to get the PID for the class that kicked off the application and then kill the Process (the first application would also have a timer to avoid it staying around if the second application did not start for some reason). I should say that there is a constraint that the main application (the second application) can only be run once and I have a bind solution to avoid this. I was wondering if there is a better way to terminate the first application. Should I use RMI or another way to tell the application to exit? If possible the less networking the better.

Wouldn't the ant Splash task do the trick?
This task creates a splash screen. The splash screen is displayed for the duration of the build and includes a handy progress bar as well.

in your first application (splash application) create a server socket with port XXX and listen for incoming messages, and apiece of code to terminate itself (e.g. System.exit();) when a message is received, and in your second application (when it is up) send a message to port XXX.
you also can implement a similar scenario using files. (1st application periodically checks a specific file exits and when it founds that file exists it terminates, 2nd application generates that specific file when it is up...

Related

Standalone application inside tomcat

I have a simple java class that i want to run programmatically. This is basically a video player. It is also deployed along with my web application in tomcat. This should run upon a click on a particular link. From controller, here's how I run it
new Thread(() -> {
VideoPlayer.main(new String[]{});
}).start();
It is working fine. But every time I close the Video player, tomcat is also terminated. Any ideas on how to correct this?
Your GUI probably calls System.exit when you close it. That'll take-down Tomcat since they are both running in the same JVM. Find and remove the System.exit and you'll find things work-out better for you.
Also note that it doesn't make any sense for a web application to launch a video player. Think about it: once the web application is no longer running on your own personal development workstation, the video will be played on the server where there isn't anyone to watch it. The server probably won't even have a monitor attached to it. Most likely, you'll get a whole series of exceptions from the video player telling you it couldn't initialize itself because there isn't any graphics environment in which to start.

Run background code all the time when Android device is up

I want to run some code (mainly record system logs) in the background every certain time. This code runs all time when device is up. I have an app to control the start and stop of this recording code. I have tried putting the recording code in the service, but I found that the service always stops when app exits. This is not what I want. This function needs no notification.
BTW, this function is only for my custom Android system. So I have enough privileges such like system, driver or root. But I still want a way that is "high“ enough and affects the system least. So some normal java code is best, the kernel c/c++ modification to the custom OS is my last choice.
Thx.
Make a service class and give the permission to the maniefest
Here is the example...
https://developer.android.com/training/run-background-service/create-service.html
and do your stuff in the service, you can set time interval for that.

How to trigger a method to start at a certain?

I need a piece of code to start whenever it it 11 AM everyday. I do not want to use windows task manager or any other external things to start my app.
I need my app to trigger my method whenever it is time, 11 AM.
I have the following questions:
1) Is there any "Time Listener" (similar to action listener) that would do that
2) Is it ok if my app is always runs without closing
As others have suggested, you can use the Timer class in java (java.util.Timer) or for finer control the Quartz library (that library uses the Unix cron style).
And yes it is ok if your app runs without closing. You can run it at the background but you might be better adding notification icon in the taskbar to ensure the user can find your app when they need to.

Downloading large file from FTP server on Android causes a prompt for "Force Close" or "Wait"

I have an app that downloads a file from an FTP server upon tapping the file in a listview. Once the tap is received the download starts. This causes my app to become unresponsive, in logcat it is giving me the debugging info from the server and it is downloading just fine, the issue is this. If the download takes too long say over a minute or so android thinks the application is froze and asks if the user wants to Force Close or Wait. How do I prevent this?
Use worker threads, refer to Handling Expensive Operations in the UI Thread, http://developer.android.com/guide/appendix/faq/commontasks.html#threading
since the download is taking so long the UI thread is doing nothing. Android assumes your program is stuck and offers to kill it since it isn't making any "progress." Use another thread to download anything.
Everything that takes even a small amount of time needs to happen in a worker thread. Methods in the main thread need to return as quickly as possible, or else your app will become unresponsive.
yeah, you should use a different thread to download the file, I would use something like a loading dialog while the file is been uploading,

android - How to check that the Process is alive or not?

I want to check whether the process is still alive or not through programmatically ,Can I do that I am trying to do it by process name in onCreate method but the issue is that the onCreate method is called always .When I check that in onCreate method I always get the process name and I can not kill the current app and switch to previous one.
Can anybody help me ?
Thanks in advance.
I'm not sure I understand why you need this. It sounds more like you are wanting to save your state between application changes (your app going to the background).
On the Android, there are no two programs running at the same time, basically (there are services, but those are different). Once your user goes back to the main screen, if they "launch" your application again, it will go to the first activity defined, unless you override some functions to restore the previous state of the application.
There is no "the previous one" to go back to.
Unless you have seriously messed around with your manifest, there will be only one copy of your application (in one process) at a time.
Refer to this article in the Android documentation, specifically the Processes and Threads section:
Application Fundamentals
When the first of an application's components needs to be run, Android starts a Linux process for it with a single thread of execution. By default, all components of the application run in that process and thread.

Categories