I want to develop a real time game for Android with libgdx. I need to update some variables even dough the game is not running.
For example I want the money to be increased 10 credits per hour (real life hour) so that you can go out of the game and come back an hour later and get that money anyway.
How can I do that?
Thanks
For real time, no need to setup your own server. Just use one of the public time server. Download NtpMessage.java and SntpClient.java from ntp site. Then run SntpClient.java with a ntp port. e.g.
java SntpClient 0.pool.ntp.org
You can use the code of SntpClient class and tweak if you need to.
When user gets out of game (pause state), get the time from ntp and save it. Once the user launches your game, get the time again and compare.
How about these two possible solutions (easy vs. difficult)
The difficult one...
To have a full control, you need to implement the logic in a server and have your application connect to it to get the credits (expensive but excellent solution). Your app will not hold permanent data. Your app will only be used for display, interaction, send/receive data from server.
The easy one...To simply use your app along with phone time. This solution costs much less but your app will be vulnerable against phone time manipulations.
Related
I am using firebase real-time database for my app. It's great but I am facing a delay of some seconds during writing data from the app to firebase for the very first time. Means every time when I starts the app it takes a time of 2 seconds to send data to firebase. And after that it works fine with great speed. I know this isn't a big delay by any aspects but in my case I seriously needed the data transfer and fetching instantly. Is there any way to reduce this delay ? Thanks in advance.
The first time you access the Firebase Realtime Database from your code, the SDK has to establish a connection to the server. This involves multiple steps, which are only needed upon establishing the first connection. This explains why the first connection may take some time, and indeed it is not uncommon for it to take one of more seconds.
There is nothing you can do in code to improve the actual connection speed. That is up your bandwidth and latency (which I assume you're not interested in changing), and the SDK and server (which you can't change).
All you can do is start connecting as early as possible in your app's lifecycle, instead of waiting with it until you need to firs read/write data. For example, consider adding a listener to .info/connected when your app first starts.
True,
hi vj Shandilya to my knowledge, the initial connection ought to take a tad longer than expected as this was the case while my team and I were working on an IoT based project linked with firebase and Android-Java.
Maybe you can add, a custom (not intense) progress animation to cover up for the 2 sec.
We want to implement a back end server [Java EE] for mobile application that sends notification to mobile on some events, I'm asking about the best/simplest approach whether Pushing or Pulling notifications, here you are my ideas/questions
1- The requirement is to send instantly the notifications to the mobile as long as the application is running no need to send if it's not running
2- I read that to push notifications to IOS or Android, I will need to connect to apple/google notifications servers, I felt that this is complicated especially that it requires low level socket programming, but based on number 1 and the project has limited time and budget, do we really need pushing ? and is it really complex
3- I read that pulling date may drain battery and consume data, but what if implementing a simple job on the mobile that runs only 3 or 4 times a day, invoking a simple web service on back end server asking for the notifications
P.S will be much appreciated if you can provide some tutorials for similar cases :)
1) If you're application is already running, is it connecting to the same location anyways? If so you might as well pull for the notifications at that point. However, if the app isn't actively connecting, i would attempt to avoid pulling.
2) Interacting with Notification servers on google and apple site directly, can indeed be a cumbersome task. However there are companies that have made this much easier for you. The advantage of using companies like urbanairship, xtify and mblox will get you started with sending push messages in minutes. (for an example take a look at http://developer.mblox.com/docs/ in the tutorial section).
3) depending on the data you try to present, end users now a days are used to instant data. I can't imagine a service whereby pulling 3 to 4 times a day is sufficient, however if your use case is truly limited to 4 times a day, and there is no other activity going on in the background process you create for this, you might as well have the background process running. But do think this through carefully... If at any point in time you want to increase the number of times a day you read, you might soon get to the point where a rewrite is needed to ensure end user satisfaction.
I'm new to the android development, and programming in general.
I'm developing app to create football statistics for each player, and in the long run I'm using SQLite to store data. However I was wondering if there is a way and if it will make sense, to store data during the run of my application without inserting it to the db, every time user is trying to add new statistics.
Also I'm wondering if there is a point in doing that, my biggest concern is that inserting data to a db all the time will slow down my app, and I would appreciate what more experienced developers do know, and think about this 'issue'
I was trying to research the topic, however all I got was storing data in db, and using SharedPreferences and I don't think that's what I'm looking for, however I can be wrong.
please help.
SQlite is what you're looking for. SharedPreferences are for just that - preferences, not large amounts of stats.
Put your database code in a separate thread and you won't notice any slow down in your app. Ask back here for help on this.
I can't speak to android directly but I have faced similar design issues on iPhone and desktop applications.
It depends on the specifics of the application as to what would be the best way. If your app is mostly about entering plays and saving statistics, I would keep a small set of the latest statistics in memory enough to populate the user interface and then create a "data manager" running on a background thread whose sole purpose was to insert these newly added statistics to the database.
Honestly, I would put it in the DB immediately. With the way android works, if your user navigates to another app (or possibly even receives a phone call) the data they have already entered could be lost.
It is possible to cover that contingency obviously (saving in onPause, etc.), but I've always felt it was safer to get the data into permanent storage as soon as possible. (Note this is a hotly debated topic, I'm merely stating my preference).
Saving to the DB immediately doesn't affect app speed (depending on how much of what type of data you are inserting) so much as battery life. Accessing permanent storage takes more in terms of power as there are several more steps the processor needs to take.
If you do all your DB activities in a thread other than the UI thread the transactions will be almost completely unnoticable in terms of app speed.
If you use implement Loader callbacks it should not slow your application down. Have a look at the Loader classes. They are available through the Android compatibility library.
I am trying to make an online application that will be like an online exam, But I want to ensure that no user can browse internet during the test. Is it possible ANYHOW?
I am thinking about a fullscreen application that don't minimize. But that cannot eliminate the chances that user alt-tabs other window :(
Any direction is highly appreciated.
Technology is no bar. Having said that, the students will be taking the test from home.
I think this would be better solved on the network layer in your school router.
Block IP access to everything except the online test for this class room while test is being taken..
Technology is no bar. Having said that, the students will be taking
the test from home.
Do understand the spirit of laws 1,2,3 of the 10 Immutable Laws of Security:
Law #1: If a bad guy can persuade you to run his program on your
computer, it's not your computer anymore
Law #2: If a bad guy can
alter the operating system on your computer, it's not your computer
anymore
Law #3: If a bad guy has unrestricted physical access to your
computer, it's not your computer anymore
The only computers that conform to your will (in your case, you want the PCs to disallow browsing) are those for which you have complete control of the hardware and software.
You can fool only the less sophisticated users. If your users are inclined, they can easily learn to bust it. From the DRM fiasco and certain personal anecdotes from school and college, its well proven that the users can be one step ahead and trying to close the gap is a black hole for money and effort.
Also the kids are at home. They can always use other devices or means. You can make a page with javascript that can prevent it from going out of focus, but a 10 year old can learn to open another window. Make a fullscreen desktop app that checks if the mouse is "inside" , a 16 year old can run it on a virtual machine or screen session. Yes, I was that smart at that age and kids are getting more smarter than you or me.
Also, automated systems to detect wrongdoing are likely to take innocent victims and cause pain and resentment. Internet filters that trip on "Steve Jobs death" and "new c# jobs" for the same reason are an annoyance. Payment processors and site advertising with automated fraud detection algorithms and customer care that stonewalls have made people broke.
You could also set a system (IE) proxy, and write a small Proxy Server to intercept any outbound requests and return nothing
Writing such Proxy is trivial...
If you are on Windows, you could write a batch file to start your program and use the REG command to modify the registry key(s)
I'm working on a solo project, using the aforementioned technologies. The aim is to create an quiz game for Android. The questions are created by the "quiz master" online beforehand and submitted to a MySQL database. They are then retrieved by the Android application. I have set up the link between phone & server using PHP, with the data sent over in JSON format.
I want each question to have a pre-allocated time which the user has to answer it and once this has elapsed, the Android app to prevent the question from being answered. The time is chosen by the quiz master and submitted to the database along with the rest of the quiz information.
As not everyone might retrieve the quiz from the server onto their phone at the same time, there are problems with regards to making sure someone doesn't get longer to answer the question than the other. As far as possible, I want to keep everyone in sync. It'll be difficult to make sure everyone has exactly the same time, but I'd settle for just having people not being able to delay retrieving the quiz and then getting the full 30 seconds (or whatever). For it to be fair, the countdown needs to start once the quiz has been started by the quiz master.
I'm struggling to think of a way to overcome this problem. I have a very basic client-server system set up and I can't think of a way to have the server keep track of the "time left" and then send a number to the phone, indicating the amount of time left.
Sorry for the essay, hope someone out there has an idea! It would be very much appreciated!! :)
All the best,
J
Perhaps you could have each users device keep track of how fast they answered the question and then compare the response time after the answer is submitted. For example: The server sends the phone a question and tells it that there is a 30 second time limit. As soon as the user views the question, the timer starts on their phone. Then say it took them... 14.79 seconds to answer correctly. The phone would send the info back saying how long each user took then compare them to see who answered the question first and who all answered within the time limit. This technique may not keep the quiz game perfectly in sync across all connected devices, but it should keep the game fair.