How to schedule an Android FTP upload and download at timed intervals? - android

I am developing an activity that on the press of a button, downloads a text file from a remote server via FTP containing several numbers. On the press of another button, a text file is created with various stats depending on the numbers (CPU useage, SD card free space etc) and FTP'd back to the same server.
All this is working fine, but the next stage of development is to make the app do all this at timed intervals, all in the background without showing the GUI (which will only be used for setup).
I've never done this before, so I had a dig around on the web, it seems I will need to use Alarm Manager, but I don't have a clue where to start.
Can someone point me in the right direction please? It would be helpful if someone could give me an answer that ties in with my particular problem rather than saying "go and look on so-and-so Android website".

For background things read:
http://developer.android.com/reference/android/app/Service.html
If you want to do this with intervals you can use: http://developer.android.com/reference/android/app/AlarmManager.html

Related

i am finding it difficult to spawn an android device and interact with it programmatically

Basically, I want to be able spawn an android device online through services such as genymotion cloud. But that is all I have been able to do with gmaas but I want to also be able to send commands to open a specified app and build a set of commands to do something within the app launched.
PS: i have done my research, its just that noone seems to want to go past authentication and sprawn a device. What i don't understand is how to feed the next page in their input boxes.
Any help will be appreciated even if all you have to give me is just an idea, I am certain that I can turn it into gold, i mean code.

In App Downloading of an Excel File Not Working

First of all, let me emphasize that we are not looking for a specific code snippets for a solution. We believe that this problem of ours started with some design flaws. So we are looking for a general direction with which we can start looking for specific methods to solve this issue.
We have an app that has an notice board where admins and users can create threads.
However, we made a thread where people can download our excel template. We posted our link to this excel file like so:
(I apologize for non-English thread as we are located in Korea)
So in this thread page, the image in the middle is the link.
When you tap(click) on this image, a more detailed download page shows up.
When you press the download button, nothing happens. It is supposed to automatically lead to downloading process but it does not.
I suspect that the problem resides in our application structure where whatever a user does in the thread stays in the webview and webview only. Is there any way to make this download take place? The only workaround we found is to press and hold the link button until some options show up and press "open in the browser". However, this is quite inconvenient for normal users and we need to fix this.
Thanks a lot!

Android off-game click tracking

I would like to know if it is possible to have a process that would constantly run on the phone and would track the number of times a user taps on the screen.
For example, the user downloads a game, plays and then quits the app and although he quit the app, this process that got installed together with the app will still run and all that it would do, is that it will increment a value every time the user taps on the screen and then remember the said value, in order to be used the next time the user starts the app.
I don't know if this is a simple question or not but please keep in mind that I am new to Android development and I did not find any related topics on this.
Thank you in advance.
Yes, it is possible. Using certain flags on your service, you can create a system-wide overlay that should allow you to catch all click events systemwide. However, keep in mind that it seems that Google have tightened up security in Android 4.x, so you may have trouble getting this to work on more up-to-date versions of Android.
For specifics about implementing this, see this question: Creating a system overlay window (always on top)

How Change Date and Time inside my App (not via settings), best way to do it?

I'm building an app that will be bundled with an equipment. I want to block all access to Android settings, there is not physical button to go back, only touchscreen. So this won't help: startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
I want to change time and date of the device through the Application. I researched a lot and every solution I've found to change time and date programatically in Android seems to be over complicated (putting the app inside system/app or something).
As I've come to know, having superuser access and declaring SET_TIME on AndroidManifest only doesn't help.
The application must display hh:mm dd/mm/yyyy
In my App settings, the user may set the date as being 13/01/2014 (dd-mm-yyyy), but let's say today is 10/01/2013. In my app I would do something like this today+offset (3 days). The same goes for the clock.
I was thinking in creating a thread that keeps track of the current time to update the text field with the current time (+offset defined by the user) every minute and another to update the date (the machine may work for a very long time), where I format it using the offset the user configured in the App. I don't like this solution, however I'm not sure if Android has another more efficient way to do this kind of task.
So the question: Is there a better way to do it other than using threads?
I was thinking in using a thread with postAtTime(), I guess it's more efficient than being inside a loop and checking if the time/date has changed from time to time.
I found out the answer I needed here: Setting system time of ROOTED phone
My Android device is rooted and using CrazyCoder solution worked. Although it will not work on Android emulator, but with rooted device.

Is it possible to load a file into an app from another app?

I'm interested in writing a generic frontend app for Android. I'm thinking along the lines of a media center like XBMC.
This frontend app would (hopefully) be able to read files on a sd card and load those files into a 2nd app (which it would then launch).
Ideally - I would like the frontend to lie dormant once the 2nd app is launched. I would then like some tiny, low-overhead listener app to run in the background and wait for a specific button press (probably the back button). Said button press would then close the 2nd app and force the frontend app to appear again in place of it.
Has anyone tried anything like this? Some code snippets or tutorial links would be hugely appreciated.

Categories

Resources