What I want to achieve is to capture a current foreground activity and save to bitmap file. I need to handle taking that screenshot in a background service. I have run through many ideas, tutorials that mainly uses invoking getWindow() method and enabling cache. However that approach is useless for me - it is impossible to get reference to the foreground running activity (isn't it?) - using ActivityManager I can get only the name & package of it.
I came across the ASL (https://code.google.com/p/android-screenshot-library/downloads/detail?name=asl-1.2.zip&can=2&q=) which uses "native service" which is available in compiled binary file. Library's wiki note states that you have to start the native "screenshot service" by ADB using pc.
My question is: could it be possible to start that service programmaticaly through java code, something like JNI (using NDK) does?
On a rooted device, you can start the service from Java with
Runtime.getRuntime().exec("su")
On custom system, you can start the service from /init.rc.
NDK will not help, anyway. Going C does not compromise the system permissions.
Related
I would like to write an Android app (not a PC program) that has a subset features of Android Device Monitor (ADM), ie. select a process and trace its method calls, with detailed information (all the information that ADM can get, like stack trace and time), while the phone is not connected to any computer nor does it have any network access.
I've searched into android.os.Debug.startMethodTracing*, but it seems can only trace current process and the result can only be written into a file (I need the info in memory).
Digging its implementation, I found dalvik.system.VMDebug.startMethodTracing*, but it seems cannot be used by apps and I didn't find a way to specify pids, neither. Looks like it's calling JNI functions, but I didn't find the implementation.
Maybe I can get the information by lower level way by using Linux perf events (perf_event_open(2)). But before doing that, I would like to know if such kind of feature possible to implement purely in Java (maybe by talking to some "system manager" process or "debugging server" process, or by calling some CLI tools then get its stdout)?
These capabilities can only be accessed by the shell user (the user that adb runs as), or the root user of course. By design, a normal android application cannot access these features, because this would completely break the application sandbox that is the basis of the application security model in Android.
I'm looking to build an app that will restart my device at a specified time, then open up a couple 3rd party apps in sequence and run their feature/s.
For example: I would like to automatically restart my phone at 5am. Then have it open an antivirus app of my choice and run the scan. Then close that app and open up another app and run it's cleaner function.
I have experience coding, but I'm just starting to take a peak into android app development. So, I was wondering if this is something feasible to do.
Any advice would be appreciated!
I am not sure about the starting phone at the desired time, but I am sure you can start applications on boot using "init". Linux systems support that, and android does as well. But it completely depends on your kernel.
Read here about init.d.
Check if your phone's kernel supports init.d. Check here if your phone doesn't have init.d support.
Check Here for running a script at boot. It is quite useful for custom scripts.
Check Here for running scripts/application the application at boot
Create a script according to your needs and I think you would be able to achieve what you are looking for. <- Custom Rules
I would have commented but apparently I can not since I am new here.
I hope I was of some help. Will look into the android starting part and get back to you.
Cheers.
I need to write a service that will take screenshots of the current screen at specific intervals.After studying I found that there are two ways to do so :
By rooting the device and access system level privileges to read framebuffer and convert it into a bitmap
2.Use ASL library to take screenshots
Since I don't want to root the device,I decided to go with ASL but whenever I run the demo code,I get native service not found.Please suggest me the steps to implement ASL and make the code to work.
In order for ASL to work, you have to connect to a PC once after every boot, and start the native service via ADB.
I guess you missed that, thus the service is not found.
You can find more on that here: http://code.google.com/p/android-screenshot-library/wiki/UserGuide
i want to make an application or more like a tweak for android
i want to write some code that's gonna work on an android device and will do curtain actions based on an input from a Bluetooth device
this application needs to run in the background at all times (as if it was part of the device's operation system)
and be getting input every second
i need it to be able to bring up i custom keyboard i am gonna design and to set up a courser just like in a desktop which can be controlled by the application.
i read about something called a ROM and i dont know if thats what i am looking for.
i also know that the android operation system can be modified or replaced with another operation systems like the one called cyanogen .
i am a beginner and i have got some background in java
i tried creating an android app but i dont know how to make this thing work on the OS
i need someone to give me a very detailed explanation cause i know nothing about these stuff
It sound like your trying to make an App that takes Bluetooth input...
It doesn't sound like you need to edit the OS itself...
You need to set up the Android SDK to start development...
http://developer.android.com/sdk/installing/index.html
1. Download the SDK
2. Install the Eclipse Plugin
3. Write the code, and run it on the emulator or your connected device(make sure debugging is enabled under Setting->Applications->Developer)
Here's some info on getting started w/ Bluetooth...
http://developer.android.com/guide/topics/connectivity/bluetooth.html
Since you want this to run all the time, I would look into Android Services also...
http://developer.android.com/reference/android/app/Service.html
You may want to also take a look at the Sample Projects included w/ the SDK after you download the SDK and set up your IDE and Emulator(or phone)...
http://developer.android.com/tools/samples/index.html
Hope this helps clear some stuff up...
I need to profile dynamic library calls of android application and have decided to profile using "ltrace" tool for this purpose. I combined "ltrace" tool into android package, then compiled together successfully. It works fine with shell program just like usual linux console application.
However, I cannot properly profile android applications, which are forked from "Zygote" process. I tried attaching ltrace to "Zygote" process to follow child processes of it, but I only got SIGCHLD and SIGSTOP signals and terminated abnormally, showing the following errors.
unexpected instruction 0xffffffff at 0xffff0508
I'm just wondering if anyone has ever tried this kind of profiling on android system. Any short comments can be very helpful for me.
Thank you in advance.
Try attaching ltrace to your android application's process after it is it forked off zygote. You will need an ltrace built for android's bionic libc, and one that has reasonable handling of threads.
There is a way to set a debuggable android app to wait for connection of the java debugger, you could use that, connect ltrace, and then connect and disconnect the java debugger to start it going again. This should capture most of your own logic, though not the entirety of the startup.
IIRC you are under a time limit to connect and get it going again, otherwise it may resume on its own to avoid triggering an application not responding situation.
It may be that you will learn more by using the java debugger to see what is going on, and then reading the source to see how that is implemented on the native side.
Mr. Chris Stratton's way will work.
LoadLibrary() is another point to break for debbuging jni.