how to run application in background in android? - android

Hi, I want to make an Android application that continues to run in background and when user accesses any folder, picture, or any other file it notifies using toasts that he accesses this file(filename).

The other people answering your question are focused on the "background" part, and a Service would indeed accomplish this. Users have fairly loudly stated that they despise constantly-running services like the one you are proposing.
when user access any folder or picture or any file it notify using tosts that he acess this file(filename).
For files that you can access yourself (e.g., those on external storage), you can use FileObserver class.

Use FileObserver to detect file access or change.

Related

FileObserver on system files

For a survey I want to monitor user-compelled changes in the Android M application permission settings.
I decided to create a FileObserver watching /data/system/users/0/runtime-permissions.xml. This file holds all information but only has read/write access for the system -rw-------. chmod won't work because access privileges are restored on every change. So my monitoring app needs system permissions.
I followed this method to deploy my app directly to priv-app directory. Works like a charm, app is considered a system app, but still does not have permission to read the above-mentioned file. File.canRead() fails just as File.exists().
Is there maybe something I have to add in the AndroidManifest.xml to make it work, or is making use of the priv-app folder a complete wrong guess? Do I have to sign the application? For final deployment I wanted to add the application to a custom rom using some kind of kitchen.

Changing how android opens files so that it triggers a system service function

Where in AOSP code would I look to add code that triggers a custom system service whenever the user attempts to open a specifically named file?
For example, if a user opens a file on Microsoft Excel on Android, I'm assuming the application is creating a fileinputstream to read in the spreadsheet.
I followed the instructions on http://processors.wiki.ti.com/index.php/Android-Adding_SystemService
All files open by any process are reflected in /proc. I would either modify the procfs to get immediate and full track of such events, or if the requirements allow, retreat to a less penetrating approach, monitoring /proc once in a short while.
See also How do I monitor opened files of a process in realtime?.

how can I input information data when app is in first startup?

I want input data in internal storage of my app when my app installed in new device & never change(delete & update &insert). my information is heavy & if I input my information in oncreate() every time that user open my app information will be make again & I don't like it.how can I do it?
Create a class that is a Broadcastreceiver and register it in your manifest to receiver Intent.ACTION_PACKAGE_INSTALL actions. It will be called only when the application is installed.
You can use assets folder and put your heavy data there. It will be installed with application package. You can find information about that here.

intervening Android Install-time Permission granting mechanism

I'm new in Android. I have an Idea to enrich user's knowledge whilst installing a desired application.
the idea is developing an application that can analyze .apk file of the application to check if it's over-privileged or not. and inform the user if this application which he's trying to install is over-privileged or not.
but since there's already a mechanism from Android which asks user's consent to grant whatever permission the application requests, I'm not sure if my application can somehow intervene this mechanism, postpone it, pause it or it can not.
I'm not sure if my application can somehow intervene this mechanism, postpone it, pause it
None of these are possible, sorry. You are welcome to create your own custom firmware that has this feature, but you cannot create this capability via an SDK application, for obvious security reasons.
I am not far from where you are ~ the entire mechanization you seek is based on an xml file in the "root" of the installation - it is called AndroidManifest.xml = all permission based issues should begin original first efforts on that file:
The AndroidManifest.xml File
Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. Among other things, the manifest does the following: .....
the "app-store" web based distribution system is supposed to pick that up and not only make some decisions on what to present to the user but as well differentiate to some extent what to do in the matter but as I just got a Droid-X emulator available in my installation I can tell you for a fact that "versioning" is subject to oversimplification as we cannot rely on users being tech-geeks

Android : Monitoring folder activity

I want to create an app which would monitor changes to data in a folder on SD card.
For example if a file is put in a folder, as soon as file is copied, my app would send this file to server and delete this file.
Is it possible to do this?
Thanks.
I think you can use android.os.FileObserver which is available since API Level 1.
Source: http://developer.android.com/reference/android/os/FileObserver.html
I looks like there is no system-wide "FileSystemMonitor" you could connect to.
So you have to write it yourself. You could for example receive the ACTION_TIME_TICK broadcast and check the filesystem for changes yourself every minute using the normal java File classes.

Categories

Resources