I have some very basic questions, Great to get answer.
Q 1. Whenever anyone creates android application which generates *.apk file and installed this apk on device, can we surely say that android has created new process for this apk ?
Q 2. If Android app manifest file has tag for application and inside it has service only. and If it installed on device as apk.
Now this service remotely going to be access by another android application using aidl which has application tag and inside that there is Activity. which access above remote service.
can we say that service accessing App and remote service both are different process ? I think Yes.
My assumption
Any app which has tag inside manifest file and which generates apk and get installed on android device then on launch by any other App remotely or starts its own on some event intent then android framework will launch new process to start for this apk. Please correct ?
android:process can be set if any components of same application want to run in another process or different applications component want to run in the same process.
Please read carefully and then only reply, let me know if need more explanation.
R1. The apk is just a package. When you start your application, low level, the linux machine on which Android is based will fork a process called Zygote. Then the copy of the Zygote (that already has either an instance of the Dalvik Machine mapped in its address space, or the ART libraries and Ahead Of Time compiled application code), will load all application specific java classes, and all core dependencies (native libraries), plus all application specific native code.
So it does create a new process only when you start the application.And hypothetically, you could create any number of processes for the same apk, which is just a container.
R2. If in the AndroidManifest you have a service declared as "exported", it will run in a separate process. Your application will then communicate with this process using an IPC mechanism called Binder, which is a specific implementation of shared memory at kernel level. AIDL is a meta-language interpreted at build time and used to auto-generate Java stubs that will work deep down with native binder code.
Whenever anyone creates android application which generates *.apk file and installed this apk on device, can we surely say that android has created new process for this apk ?
No. Installing an app does not fork a process for that app.
can we say that service accessing App and remote service both are different process ? I think Yes.
By default, they will be in separate processes.
Related
First of all, please note that this question is not same as all the "android foreground app" questions I found on SO, please read on :-)
I'm trying to write an android app for my own use, using golang, without using android-sdk or ndk (this is the KEY point). It is pretty simple, just use golang to write a http service, compile it for arm CPU and voila my app is running and can be access by simply visit http://localhost.
For the purpose of my app, I need to know the currently running foreground application, to define it precisely:
Foreground application is the application that occupies the screen, or has an "activity" what-so-ever (forgive me I'm not an android developer).
Anything that that is depended by the foreground application (e.g. services) is NOT what I am interested in.
If the phone is LOCKED/screen turned off, I want the solution to tell me there is NO foreground app.
And since I do not use anything android, just treat the phone as a LINUX machine, I want the solution to use native LINUX ways, e.g. by inspect /proc, or by calling any installed android command line tool (including sending messages via these command line tools), but NOT using any SDK/NDK way so that I have to use java or incorporate these thing into my app.
Starting from Android SDK 26 (if I remember well) Apps are executed on -one-User-per-App, so (i.e.) WhatsApp is running on UID=30 and Telegram on UID=76, so executing a ROOT command of "ps -A -o PID,USER,NAME" you can parse output and then Kill all Processes that you don't want to be executed.
36119 u30_a149 <WhatsApp_packagename>
36203 u76_a211 <Telegram_packagename>
37399 root [kworker/1:2H]
37423 u0_a329 su
38069 root sh
Without Root Permissions nothing of what you're trying to achieve is possible simply because is not possibile to denied an application to be executed or to kill it without Superuser privilege.
I am trying to debug native code in my Android App development and I need to have com.android.server.PackageManagerServices in the device. I search the info for PackageManagerServices and can't find good info in the web.
My queries are
(1)Where to get com.android.server.PackageManagerServices?
(2)How to create this service available on the device?
Thanks
PackageManagerService is located at /frameworks/base/services/java/com/android/server/pm/
PackageManagerService is a system service which gets started by SystemServer.java at boot time and always keeps running. one need not to create another instance of it.
You can refer aosp source code at http://androidxref.com
Just starting with android.
I try to create project that will send notification ( some bit for example ) to my FTP server every 3 hours.
I don't know how to create this project because each time i create new android project i must have only project with activity - and i don't need any activity - just need a service that will run when i install it on the device.
each time i create new android project i must have only project with activity
If you are using Eclipse, uncheck the "Create activity" checkbox that tells the new project wizard to create an activity.
If you are using android create project, yes, it will create an activity for you. You can delete the Java class and the manifest <activity> entry if you want.
In reality, you will wind up leaving all of it alone.
just need a service that will run when i install it on the device.
First, a service does not run just because you install it on the device. It only runs if you write code to cause it to run.
Second, while you might think "well, I will just get control at boot time and start the service then", that is possible, but it will not work on Android 3.1+ devices unless the user has run an activity first. This is to prevent "drive-by" malware.
So, I suggest that you leave the activity in there, if you want your app to work.
Moreover, unless this app is only for yourself, your users need the activity, to:
Control the behavior of the service, such as changing the "every 3 hours" setting to something they prefer
Read your license agreement
Read your documentation, including how to get support
Etc.
I have been trying to figure this out on the web with no information whatsoever as to what this actually does. The Google Manifest information says:
Allows an application to set the maximum number of (not needed) application processes that can be running.
I am thinking this is not a third party app permission but I need to be sure, its for our embedded device.
My guess is that this limits the number of processes that one application can have open when calling android:process=".RemoteActivity" in the manifest.
Anyone? Thank you.
It's a development/debug intended permisson. And just do what it says. Remember that when you run an app, android creates a process for all it's activities. This is, if you start opening the different activities of your application, you use the same process. However, Android let's you choose if an activity uses the main process or another new one. That's why this permission exists.
Sources:
http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html
http://developer.android.com/reference/android/Manifest.permission.html#SET_PROCESS_LIMIT
I have developed an android service. Any android app can use it's API's to get some kind of news updates from this service. I want to distribute this service so that any android app on the phone can use this service. My questions here are :
When some android application try to use its API on the phone and suppose that service is not available on the phone then what will happen ?
How will android application developer will make sure that the service is available on the phone ?
Does application developer has to bundle service with his application ? If yes then wont be there multiple instances of same service on phone if multiple application contains same service on the phone ?
Thanks
Dalvin
When some android application try to use its API on the phone and suppose that service is not available on the phone then what will happen?
If they are smart, they will use PackageManager to see if you are installed first. Otherwise, their attempt to call startService() or bindService() will fail.
How will android application developer will make sure that the service is available on the phone ?
Use PackageManager.
Does application developer has to bundle service with his application?
How are we supposed to know? You are the person who wrote it.
If yes then wont be there multiple instances of same service on phone if multiple application contains same service on the phone ?
Possibly. It is difficult to answer this question in the abstract, as there are multiple ways to distribute this service (as an APK, as an Android library project, as a JAR, as just a hunk of source code) and multiple ways to integrate it (change the source code, use the source/JAR/library as-is, reference the existing APK).