[Q] Service vs. intents in the manifest file - efficiency - Android Q&A, Help & Troubleshooting

Hi,
This is the first time I've started a thread so home I'm in the right place etc.
Just working on my first ever app. I created it as a service as that's what I thought I needed to monitor the battery status, screen status etc. I created some intent filters within the program itself to do that and assumed the process had to be running to get them.
Then I read I could have put the intents in the manifest file and my app will be started up if it isn't already running. That sounds quite neat as I can get rid of the notification icon I have to have in the notification area (I had to use setForeground to stop Android killing off the service and then immediately re-starting it). But -
Am I going to use up more battery with this second method? (using intents to wake the process) I'm not sure how often Android is going to terminate my process but if it's quite often then the overhead of my app starting up and reading some variables I'd have to persist could be a drain.
Any rule of thumb help here? I know the answer might have a bit of "depends" in it but really looking for some general advice.
Thanks.
Peter.

Related

[Q] Problems with developing a custom GS2 rom for medicinal purposes.

Hello to you all people of XDA, firstly I must state that I've scoured the forums far and wide and have yet to find some valuable info regarding my problem.
So what we're doing is developing (or trying to, as is obvious from this post) a custom rom for the Galaxy S2 which would be used for a single medical application for sensor tracking and the processing and displaying of said data on the SGS2, while at the same time sending it to his/her doctor.
What we need to be able to achieve with this rom is to put it into the hands of the end-user (a chronical patient which will in turn be able to stay at home instead of being hospitalized) and be able to completely lock down the phone for his use (I know, it sounds terrible) so that he loses the phone/sms/games/youtube/internet functionality as we need the phone to run as stable and for as long as possible without any additional battery stress (the constant sending, processing and processing of data seems enough of a problem for now).
I've searched into some custom roms but we eventually came up with the need for a stock Samsung rom which could be modified as we want to.
See this is where the problem begins, we can't seem to get the phone rooted, the ROM customized and then unrooted again so that the phone can't be fiddled with anymore, except when it's completely dead and we need to fix it.
So to cap it all up:
It needs to allow for a custom load and bootscreen (I almost got this to work)
It needs to be completely locked down for the end user.
It has to have full BT, NFC and WiFi functionality
It has to be able to call out and reciev calls, but only to/from specific numbers (911, doctor, etc..)
It has to basically allow for 2-3 programs to be running, while the others simply don't exist on the phone.
I am terribly sorry if anything like this has been asked about before, I swear I put 2 days of me life into researching already.
Any help, any help at all, ideas and solutions, but mostly links are welcome.
Thank you and good day to all.
Just a detail, but the SGS2 doesn't have the NFC functionality. Project seems to be possible, I would look into CyanogenMod sources if I was you.
Sent from my GT-I9100 using XDA App
Why are you afraid of leaving the phone rooted and in hands of the patient?
Is he so uncritical that he can search the web and find means of unrooting a mobile phone and then get around to actually doing it?
LucLucLuc said:
Hello to you all people of XDA, firstly I must state that I've scoured the forums far and wide and have yet to find some valuable info regarding my problem.
So what we're doing is developing (or trying to, as is obvious from this post) a custom rom for the Galaxy S2 which would be used for a single medical application for sensor tracking and the processing and displaying of said data on the SGS2, while at the same time sending it to his/her doctor.
What we need to be able to achieve with this rom is to put it into the hands of the end-user (a chronical patient which will in turn be able to stay at home instead of being hospitalized) and be able to completely lock down the phone for his use (I know, it sounds terrible) so that he loses the phone/sms/games/youtube/internet functionality as we need the phone to run as stable and for as long as possible without any additional battery stress (the constant sending, processing and processing of data seems enough of a problem for now).
I've searched into some custom roms but we eventually came up with the need for a stock Samsung rom which could be modified as we want to.
See this is where the problem begins, we can't seem to get the phone rooted, the ROM customized and then unrooted again so that the phone can't be fiddled with anymore, except when it's completely dead and we need to fix it.
So to cap it all up:
It needs to allow for a custom load and bootscreen (I almost got this to work)
It needs to be completely locked down for the end user.
It has to have full BT, NFC and WiFi functionality
It has to be able to call out and reciev calls, but only to/from specific numbers (911, doctor, etc..)
It has to basically allow for 2-3 programs to be running, while the others simply don't exist on the phone.
I am terribly sorry if anything like this has been asked about before, I swear I put 2 days of me life into researching already.
Any help, any help at all, ideas and solutions, but mostly links are welcome.
Thank you and good day to all.
Click to expand...
Click to collapse
Block all internet access apart from ones you want or you can just setup iptables rules, shouldnt need root apart from when setting it up
As far as removing programs, just delete the apks from the zip, or before you remove root. My sig has a list of all apks in a upto date rom and what they do.
You can use gemini app manager to control autoruns (stop them etc) also to block (hide and disable apps)
As far removing root, your best bet is to once you are done, use adb (from the android sdk) to remove the superuser.apk then flash the stock kernel back, as far as I know without superuser apps cant grain root permisions.
OR
This app will allow you to block any app behind a password
This app will block incoming and outgoing sms and calls on white and blacklists
Custom boot logo (the first screen before the animation)
Custom boot animation need to go into system/media, I am not sure about the format but there are loads around, like this thread has loads, stock kernel should support them.
I hope that helps
Most of that is easily possible.
If you listed the apps needing removed, the apk files just need deleted.
To control calls, you can use a third party app from market for that.
It's possible to have the custom rom unrooted, and easily flashed, regardless of how badly the phone gets rooted
Boot animation is easy anyway... If you can provide it in a zip like other ones (zip containing numbered png's) then it's a piece of cake.
A little bit of clever firewall stuff would prevent any web traffic, in or out, except to your defined server, which is obviously a concern when a phone is handling sensitive medical info.
genieass said:
Why are you afraid of leaving the phone rooted and in hands of the patient?
The phones are going to be used by around 500.000 people in a year, it's not that we want to take anything away from the user, it's more about not having any problems with the firmware - like ever.
Thanks for all the help!
Click to expand...
Click to collapse
genieass said:
Why are you afraid of leaving the phone rooted and in hands of the patient?
The phones are going to be used by around 500.000 people in a year, it's not that we want to take anything away from the user, it's more about not having any problems with the firmware - like ever.
Thanks for all the help!
Click to expand...
Click to collapse
LucLucLuc, not sure where you live, but you're entering the patient confidentiality minefield with big, big boots.
Apart from the legal considerations, your question is definitely OS related and not device related.
I see what you want, but legally - where I live anyway - it's too much of a grey area to get involved with.
I use call recording a lot for referrals and info from other doctors, but I've always asked the other party if they're OK with it. I won't record patient conversations, and I won't accept any files whatsoever that have seen RIS or PACS first - not worth it.
Can't see it's worth your while, but I'd appreciate it if you keep me informed should you decide to work on it.
Big boots indeed
We are from Slovenia, Europe.
I'm actually just a student doing the research and some basic Android programming, thank god I wasn't let into the bigger of the projects
But yes, this project is a colaboration of several european firms and you can read more about it at chiron-project.eu - it's a very very interesting project afaic.
I don't think we'll be swimming with lawyer piranhas soon though, the project uses sensor data (which sorta is a privacy issue) which will be monitored on a tablet running Android (currently testing the Galaxy tab 10.1 - we were lucky to order one before Steve had another one of his fits), proccessed in real time and then stored on the central server, from where it will only be accessible by the patients doctor.
Patient consents are dealt with before we even start talking about mobile hospitalizations.
It's very encouraging to see some actual interest, if anyone wants to know more about anything related to this project contact me at [email protected]
Thanks again for all the help.

Smart Action app for other phones?

Didn't want to post this in the dev section but this app seems extremely useful and I was curious if there was any way of extracting it for use on other android devices?
That would be very darn useful for everyone.
I'm using tasker . . . you can do alot of creative stuff with it, but it is kinda complicated and costs ~$6
mel493 said:
I'm using tasker . . . you can do alot of creative stuff with it, but it is kinda complicated and costs ~$6
Click to expand...
Click to collapse
I have tasker as well but in general I dont find it super user friendly. From the looks of it Smart Action could replace tasker as well as juice defender which I also use.
I've already made one for home, work and when I go to bed. It seems pretty user friendly to me. Excellent app.
Heh, even if someone extracts it, it needs Blur libraries and frameworks, too.
kholk said:
Heh, even if someone extracts it, it needs Blur libraries and frameworks, too.
Click to expand...
Click to collapse
I've seen harder things get ported on xda just needs willing developers
I haven't really had a look at this Smart Action App yet as I still haven't received my microsim. I was wondering how sophisticated it is?
Is it possible to have it read sms when connected to bluetooth, for example? I attempted this with Tasker on my Defy with no success - I don't think Tasker liked MIUI very much
stunno said:
I haven't really had a look at this Smart Action App yet as I still haven't received my microsim. I was wondering how sophisticated it is?
Is it possible to have it read sms when connected to bluetooth, for example? I attempted this with Tasker on my Defy with no success - I don't think Tasker liked MIUI very much
Click to expand...
Click to collapse
Tasker does many things but in terms of doing things you need to know the proper terms for the various variables etc for what you want to do which isnt too simple
Here are some premade ones you can download or make but none for what you wanted
http://tasker.wikidot.com/profile-index
As an example of how complicated it can get with tasker is the following. How to make a battery full notification.As you can see the app lets you do allot but is not super user friendly. Smart Action may not be able to do all that tasker is able to but may be able to do most and may be more user friendly
click New and select Event
select event category Power and event Battery Full
click Done
click + in the bottom left to add an action
select category Alert and action Notify (Sound)
type Battery Full! in the Title field
click Done
To avoid getting a repeat notification within 30 minutes, we add a cooldown:
Click on the profile and select Profile Properties
Slide the Cooldown Time slider to the far right
Click Done
Alternative solution to avoid repeat notifications (added by b00ky)
Set a variable such as "%BFN" to 0 anytime you plug in your phone
Edit the "Notify Sound" task to only run "If %BFN < 0"
Add a new task "Tasker » Variable Set » %BFN to 1"
This has worked for me and makes sure you only get notified ONCE while it is plugged in as opposed to after 30 minutes of cooldown.
I'm new to this so I apologize if this is not a good way to do this, but it works for me.
An alternative to the alternative to avoid repeat notifications. If you tend to leave plugged in for long durations, 30 minute cool down may not do it for you. The below gives you a one time notification that your battery is full, and wont repeat until you unplug/replug back in. phonedude
Profile - Battery 100%
Event - Battery Full
Enter task -
1. Play your sound
2. Set Profile Status {Battery 100%} to Off
Exit task-
n.a.
Profile - Plugged In
State - Power (Source = Any)
Enter task -
1. Profile Status {Battery 100%} to On
Exit task-
1. Profile Status {Battery 100%} to Off
Thanks for that fidorulz! Much appreciated. I notice on that site that the guy tried to get the read SMS to work and failed, tried again and got it working but doesn't know how!
http://tasker.wikidot.com/readsmswhileincardock
I found a walk through on here that would not work either and I assumed it was because of MIUI, as Tasker didn't register any SMS being received. It seems that the %SMSRF and %SMSRB variables only get initialised when an SMS is received.
I will patiently wait for tmobile and the royal mail to get their fingers out and deliver my microsim and I will give it another go
I use "Setting Profiles" pretty simple and powerful, a lot easier to use than tasker (although not quite as powerful in the nitty-gritty) but definitely hits the 80/20 rule. It costs, but I believe there is a free version to try out the functionality and see how you like it.

Lifecycle question

I'm a fairly new Android developer and am trying to get a better
understanding of how to handle the lifecycle events.
First, I'm under the impression that every new screen I create for my
app is an activity in it's own right. Is this correct, or is there a
better way to display different screens within the same activity.
If every screen should be it's own activity, how do I manage something
like a network connection that I want to keep alive for every screen,
but I want to disconnect from when the app actually goes away? Do I
need to handle the app being destroyed in every activity?
Before JellyBean this wasn't that much of an issue as the user pretty
much "backed out" of the app to get rid of it, so handling it in the
main activity was fine. But now I can switch between apps and kill
the app no matter what screen it's on, so that's causing me some
issues.
Thanks,
Dan
About your first question:
I hate that too lol. What I do now is declaring 2 screens in the layout file, but set one to visibility="gone"
Now when you want to switch to the other screen, do:
MainScreen.setVisibility(View.GONE)
SecondScreen.setVisibility(View.VISIBLE)
That will switch the screens.
Second question: network actions should always be done in a background service. At least I think they should; my app crashed when I wanted to do it in an activity.
I don't have an answer on the last question, sorry.
Hope I helped!
Sent from my Galaxy Nexus running Android 4.2 JB

[Q] Android touch data logs

For a research I am doing, I need to some way to track user touches when they are using the phone in general daily basis. The user will be fully aware about what they are recording. Any method to do would be great.
What have I tried so far?
Method 1. Create an service with overlay transparent view.
Problem Due to obvious security flaws this is prevented starting with ICS. The input touches on the transparent view is not transferred to background and hence user is not able to interact with phone normally. I tried various methods with overlay view defining as type phone or type system alert or switching between them during program execution.
Method 2. View with 1% screen size make with touch outside model
Problem As problem as previous. Touch outside only returns the if touch event happened outside without even initial x, y coordinates.
There are other methods I tried but those are highlighted. Currently, I am thinking about other options:
Option 1 - The pointer location option in developer options: In settings there is this pointer location option that I can utilize. When that option is on, all the info about touch are shown in the top panel. If I can have access to those data afterwards that would be fine too, despite the fact that there will be drawings on the screen when user is using the phone. I have traced the source code of ICS and found the core class that is making that tracking possible. I recreated that class into an service. The logcat shows all the info about touch when I am running it from app. Only problem is the same as problem 1. I cannot track it outside current app. So, if it logs the tracking info even when pointer option is turned on, how will be able to get the information later to use?
This option seems the easiest.
Option 2 - Android NDK If above method is not possible is it possible to do so using NDK? Right direction to this route is also great.
Option 3 - Custom ROM Do I really need to go for Custom ROM while doing this? I am pretty sure this is 100% sure way to do it. But it is seeming very impractical in this particular research and would like to avoid as much as possible.
I would appreciate any suggestion to the path that I can follow. Thank you all in advance.

Ineducable noob seeks to irreversibly remove wifi/data access for cheapest smartphone

Hi,
Apologies if this is in the wrong thread category.
I'd like to permanently remove internet access from either a whole phone or from selected apps. This would create a dumbphone with a touchscreen. This is to tackle a net addiction, yet leave me with the capability of communicating with family via SMS. Existing dumbphones don't have touchscreens and often cause me excruciating pain to use, because of a condition I suffer from called fibromyalgia, which mimics the symptoms of RSI. Autocomplete on touchscreen phones reduces the number & intensity of finger-touches I need to make to type an SMS and are thus relatively freeing.
Would anyone know how this could be done, please? I rooted a phone once or twice but am not capable of following any instructions which require judgement. Please don't take more than a couple of minutes over this because there's a strong chance any advice will go over my head.
With thanks in advance for your thoughts
Jonathan
joanthan75 said:
Hi,
Apologies if this is in the wrong thread category.
I'd like to permanently remove internet access from either a whole phone or from selected apps. This would create a dumbphone with a touchscreen. This is to tackle a net addiction, yet leave me with the capability of communicating with family via SMS. Existing dumbphones don't have touchscreens and often cause me excruciating pain to use, because of a condition I suffer from called fibromyalgia, which mimics the symptoms of RSI. Autocomplete on touchscreen phones reduces the number & intensity of finger-touches I need to make to type an SMS and are thus relatively freeing.
Would anyone know how this could be done, please? I rooted a phone once or twice but am not capable of following any instructions which require judgement. Please don't take more than a couple of minutes over this because there's a strong chance any advice will go over my head.
With thanks in advance for your thoughts
Jonathan
Click to expand...
Click to collapse
Root your phone based on your past experience.
Install Xposed Installer app.
Install xposed framework by clicking install button in the app.
After a few minutes, your phone would ask for permission to reboot.
Reboot it.
It will take around 10 minutes or more to reboot.
Open the Xposed Installer app and click the menu icon on top left of the screen.
Select Downloads.
Search for XFirewall and install it.
Reboot.
Open XFirewall.
Select which apps you want to have net connectivity.
OR
You can try any other normal firewall app if you think it to be better than XFirewall
Augustoandro said:
Search for XFirewall and install it.
Reboot.
Open XFirewall.
Select which apps you want to have net connectivity.
OR
You can try any other normal firewall app if you think it to be better than XFirewall
Click to expand...
Click to collapse
Thanks Augusto! Much appreciated.
Do you or does anyone on here please know of any firewall apps which allow the user to commit to a period (24 hours, a week, a year, permanently) without network access? Unfortunately without this kind of restriction I can't trust myself to stay off the web. Five minutes reading the news or Twitter always turns into five hours.
Thanks

Categories

Resources