[Q] Restart service after kill - Java for Android App Development

Hi I want to start my service after it is killed by the user or the system.
I thought about creating a second app and monitor if the service is running and if not then start it.
The problem I have with that is
- I need two apps
- It drains more battery
I hope you can help me find the best solution for my problem

Yeah, I think if you override the onDestroy method on your service class, and then you can send a broadcast from there.
In your broadcast receiver you can start the service again.
Though i have never tried it myself, i think this should work.
Tell me how it goes
Happy coding!! :thumbup:
Sent from my GT-P3100 using XDA Free mobile app

hiphop12ism said:
Yeah, I think if you override the onDestroy method on your service class, and then you can send a broadcast from there.
In your broadcast receiver you can start the service again.
Though i have never tried it myself, i think this should work.
Tell me how it goes
Happy coding!! :thumbup:
Sent from my GT-P3100 using XDA Free mobile app
Click to expand...
Click to collapse
I thought about that too but unfortunately when the app is stopped by the user the onDestroy methode is not called...
Sent from my SM-N9005 using XDA Premium 4 mobile app

If yu are using android version less than 4.4.2 then returning start sticky should do it
Sent from my GT-P3100 using XDA Free mobile app

hiphop12ism said:
If yu are using android version less than 4.4.2 then returning start sticky should work
Sent from my GT-P3100 using XDA Free mobile app
Click to expand...
Click to collapse
That is only if the system stops the service not if the user does....
Sent from my SM-N9005 using XDA Premium 4 mobile app

Rick Clephas said:
That is only if the system stops the service not if the user does....
Click to expand...
Click to collapse
I believe there is no such way... otherwise android would be very insecure for malware that just does this . You can only restart your service once the user restarts your activity, there should not be another way (and START_STICKY for the system of course). And please don't do two apps which listen for each other, if the user willingly kills your service they usually have a reason and expect that your app is not working right until they restart it.

SimplicityApks said:
I believe there is no such way... otherwise android would be very insecure for malware that just does this . You can only restart your service once the user restarts your activity, there should not be another way (and START_STICKY for the system of course). And please don't do two apps which listen for each other, if the user willingly kills your service they usually have a reason and expect that your app is not working right until they restart it.
Click to expand...
Click to collapse
I have heard that a lot but does that mean that all the security apps available on the play store can be killed by the user? :what:
Sent from my SM-N9005 using XDA Premium 4 mobile app

Rick Clephas said:
I have heard that a lot but does that mean that all the security apps available on the play store can be killed by the user? :what:
Click to expand...
Click to collapse
Sure, why not? I could uninstall my firewall on my PC if I wasn't using Ubuntu and thus don't really need one

SimplicityApks said:
Sure, why not? I could uninstall my firewall on my PC if I wasn't using Ubuntu and thus don't really need one
Click to expand...
Click to collapse
Well that is a pitty. I really thought I had seen an app that could do that...
Sent from my SM-N9005 using XDA Premium 4 mobile app

Look this app says it can't be killed by task managers https://play.google.com/store/apps/details?id=com.domobile.applock
Sent from my SM-N9005 using XDA Premium 4 mobile app

Rick Clephas said:
Look this app says it can't be killed by task managers https://play.google.com/store/apps/details?id=com.domobile.applock
Click to expand...
Click to collapse
Just an idea, it might be possible when your app is a Device Admin with the APIs that you get with that. Though you have to read it yourself, I have no clue about how it works.

SimplicityApks said:
Just an idea, it might be possible when your app is a Device Admin with the APIs that you get with that. Though you have to read it yourself, I have no clue about how it works.
Click to expand...
Click to collapse
Thanks I will look at that. Most people have my app as Device Admin because that way it can't be uninstalled
Sent from my SM-N9005 using XDA Premium 4 mobile app

Well I found the solution.
When device admin is enabled the app can't be force-stopped or uninstalled. Then the user can only stop the service and then the onDestroy methode is called so then I can restart the service again. Tanks guys :thumbup:
Sent from my SM-N9005 using XDA Premium 4 mobile app

Related

[Request] "Siri Proxy" alternative for Android ?

Siri Proxy allows you to control additional devices with a Siri device. So I thought there must be something similar available for Android.:fingers-crossed:So we can also control our garages with Android devices
http://www.youtube.com/watch?v=NUJ5z76Xv5o
http://arstechnica.com/information-...ons-that-show-how-amazing-the-tiny-pc-can-be/
https://github.com/plamoni/SiriProxy
So many views but no reply ?
Sent from my GT-I9100 using Tapatalk 2
Can't this be done with Google Now? Seems like it would be a feature.
Sent from my YP-G70 using xda app-developers app
damnyouwaffles said:
Can't this be done with Google Now? Seems like it would be a feature.
Sent from my YP-G70 using xda app-developers app
Click to expand...
Click to collapse
Yes, something has to be done with Google now
Sent from my GT-I9100 using Tapatalk 2
I'll look into it.
Sent from my YP-G70 using xda app-developers app
look on "utter" in playstore with tasker you can put event on it - you down't need to be online.
meo said:
look on "utter" in playstore with tasker you can put event on it - you down't need to be online.
Click to expand...
Click to collapse
It is all in beta.
Sent from my GT-I9100 using Tapatalk 2
I have been wanting something like this as well.
To have an application to do this though, you would have to have two parts two it.
First part would be an app on your Android device, and the other part would be something that runs on a computer @ the house.
Reason for this is because you would want a secure connection between your phone and the app. Otherwise, anyone/everyone would be able to access your home automation system.
If there is anything like this, that would be awesome, but I don't think there is
The closest thing you can get to it is HomeSeer, but it isn't voice activated. It's only buttons.
If anyone knows of a program that would do voice activation home automation, please let me know!

whats a good ad blocker now ad away is gone

i read something with apk
i dont know how to do that
track 1 said:
i read something with apk
i dont know how to do that
Click to expand...
Click to collapse
Man, you have a long way to go...
Sent from my Nexus 4 using xda premium
track 1 said:
i read something with apk
i dont know how to do that
Click to expand...
Click to collapse
Adaway isn`t gone, get it here https://code.google.com/p/ad-away/ and please learn how to use Google and most of all READ.
Or use adfree. (need root)
Sent from my Nexus 4 using xda premium
Unjustable said:
Or use adfree. (need root)
Sent from my Nexus 4 using xda premium
Click to expand...
Click to collapse
Adblockers always need root afaik.
Just google it and download an apk!
gee2012 said:
Adblockers always need root afaik.
Click to expand...
Click to collapse
I think adaway or some other ad blocker worked without root for ads over WiFi. For some reason though none of the adblockers I've tried work over mobile data for me which is incredibly annoying since I haven't had an ad (on my phone or PC) in years pretty much.
track 1 said:
i read something with apk
i dont know how to do that
Click to expand...
Click to collapse
i don't think you are familiar with installing apk's to your phone. I just want to mention that google would have solved your problem much faster . And there would be less haters around
I will explain it to you, as simple as possible.
1. Go to google and search for ad away . apk file. For example i found this link for german users: http://www.chip.de/downloads/AdAway-Android-App_56011287.html
2. Connect your Phone to your PC and move the .apk file to your phone(sdcard). Other options are using a Cloud like Dropbox etc.
3. Go to your settings -> security -> and select the option unknown source or whatever it is called in english. ( Installing from unknown source or something)
4. Go into PlayStore and load a file manager like Astro-Filemanager
5. after installing a filemanager, open it and go to the path you have moved your .apk file to... and select it
6. Press install and have fun with it
Hope i could help.
indoh said:
i don't think you are familiar with installing apk's to your phone. I just want to mention that google would have solved your problem much faster . And there would be less haters around
I will explain it to you, as simple as possible.
1. Go to google and search for ad away . apk file. For example i found this link for german users: http://www.chip.de/downloads/AdAway-Android-App_56011287.html
2. Connect your Phone to your PC and move the .apk file to your phone(sdcard). Other options are using a Cloud like Dropbox etc.
3. Go to your settings -> security -> and select the option unknown source or whatever it is called in english. ( Installing from unknown source or something)
4. Go into PlayStore and load a file manager like Astro-Filemanager
5. after installing a filemanager, open it and go to the path you have moved your .apk file to... and select it
6. Press install and have fun with it
Hope i could help.
Click to expand...
Click to collapse
you are a lifesaver
Pay for apps, don't screw over your developers.
Sent from my Nexus 4 using xda app-developers app
AW: whats a good ad blocker now ad away is gone
track 1 said:
you are a lifesaver
Click to expand...
Click to collapse
feel free to pm me if you need help in any other case.
Sent from my Nexus 7 using xda app-developers app
chrisrozon said:
Pay for apps, don't screw over your developers.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
You misunderstood, Adaway was free anyway but was removed from the Play Store for some reason. It's not piracy at all.
Nigeldg said:
You misunderstood, Adaway was free anyway but was removed from the Play Store for some reason. It's not piracy at all.
Click to expand...
Click to collapse
Sorry, YOU misunderstood. Ads equals revenue for the developer, it's the tradeoff you get for free apps.
Sent from my Nexus 4 using xda app-developers app
chrisrozon said:
Sorry, YOU misunderstood. Ads equals revenue for the developer, it's the tradeoff you get for free apps.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
That's bs. It's our free choice, if we want to look at ads or not. Maybe we should also remove the "channel change" button from our TV remotes, so we cann not switch the channel during ads?!
greg17477 said:
That's bs. It's our free choice, if we want to look at ads or not. Maybe we should also remove the "channel change" button from our TV remotes, so we cann not switch the channel during ads?!
Click to expand...
Click to collapse
The choice is watch ads on a free app, and or buy the paid version of it. Blocking ads means eventually there won't be any free apps, since the devs will be forced to charge for them all.
Sent from my Nexus 4 using xda app-developers app
Not if you don't click on them, which the vast majority of people don't anyway.
Sent from my Nexus 4 using xda app-developers app
Ad away is a free app. Some devs don't want money. Hard to give money to people who don't want your moola.
Sent from my Nexus 4 using xda premium
Devs who don't want payment don't have adds in their apps.
Sent from my Nexus 4 using xda app-developers app
chrisrozon said:
Devs who don't want payment don't have adds in their apps.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
Untrue. Some Devs make only one app with ads. And I'd gladly purchase a full version but there isn't one. So I have the choice of looking at stupid annoying ads or blocking them... If a Dev wants payment, offer ad free version. Which most devs do...with additional features. This is the way to do it.
Sent from my Nexus 4 using xda premium
What is with the sudden hate towards ad blockers now that Google has said something about them? There is a way to block people using ad blockers from launching an app and I've only seen one Dev do it, so obviously they don't care enough about that precious 0.02 a user to take actions to stop ad blockers
Sent from my Nexus 4 using Tapatalk 2

Best free anti virus

Hi I receive my new nexus 4 today, how free antivirus recommended me?
Thanks and sorry for my English is not my native language
Sent from my Nexus 4 using xda app-developers app
None. Really. None
NexusBoss said:
Hi I receive my new nexus 4 today, how free antivirus recommended me?
Thanks and sorry for my English is not my native language
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
I would recommend you Avast. In my opinion it's the greatest one, easy to use, high protection and some cool features.
Отправлено из моего GT-I9100
antivirus apps on android are pointless. the only good that a few do is help find the phone if lost or stolen. but as an antivirus they are useless.
simms22 said:
antivirus apps on android are pointless. the only good that a few do is help find the phone if lost or stolen. but as an antivirus they are useless.
Click to expand...
Click to collapse
Since you can locate your phone through your Google account now....antivirus is even more useless on android! Although Adaway is a MUST have
Sent from my Nexus 4 using XDA Premium 4 mobile app
BigDig said:
Since you can locate your phone through your Google account now....antivirus is even more useless on android! Although Adaway is a MUST have
Sent from my Nexus 4 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
Depends... they make money from ads
Ok thanks
Sent from my Nexus 4 using xda app-developers app
Install Google Play services (automatically when log into Google Play Store), enable Verify Apps in Google Settings (automatically enabled), don't sideload apks, disable USB debugging, keep the bootloader locked, encrypt the phone storage, If needed use AFWall+ and LBE Security Master.

Vzw app asking for root?

I just rooted my asurion replacement note 3 for vzw. Upon rooting and re installing some apps I got this...
Sent from my SM-N900V using XDA Premium 4 mobile app
Dra$tiK said:
I just rooted my asurion replacement note 3 for vzw. Upon rooting and re installing some apps I got this...
Sent from my SM-N900V using XDA Premium 4 mobile app
Click to expand...
Click to collapse
I would deny that request... Maybe Verizon is figuring out how deactivate root using app updates..
It's a trap!
2swizzle said:
I would deny that request... Maybe Verizon is figuring out how deactivate root using app updates..
Click to expand...
Click to collapse
Dra$tiK said:
I just rooted my asurion replacement note 3 for vzw. Upon rooting and re installing some apps I got this...
Sent from my SM-N900V using XDA Premium 4 mobile app
Click to expand...
Click to collapse
,
I agree, that does not look correct at all. That would be like asking for root access when we use my verizon app, to see how much data we've used for the month
Well, that's interesting.
It suggests that asurion is adding apps prior to shipment.
Could you check to see whether it was installed as a system app (instead of in /data/app)?
Also it would be useful to look in the system manifest (.xml file in /data/system somewhere) to find out what privileges it has?
e.g. with network + other privs (device serial #) it could have already turned you in, as it is not normal for a "su" binary to be present in non - rooted devices, whether or not you granted the app root rights.
I am also curious if the boilerplate legal docs you signed with asurion have you granting consent for them to monitor you... mind looking that up?
Sure I can look that up.. I did dent that request
Sent from my SM-N900V using XDA Premium 4 mobile app
Here are some screen shots
Sent from my SM-N900V using XDA Premium 4 mobile app
It is in system app
Sent from my SM-N900V using XDA Premium 4 mobile app
Screen
Sent from my SM-N900V using XDA Premium 4 mobile app
Shot..
Sent from my SM-N900V using XDA Premium 4 mobile app
Disregard
Well, I'm guilty of not looking on my own device.
VMS.apk is part of the distro. Kinda odd that the package name starts with com.asurian. rather than com.vzw. or com.verizon. though - maybe Verizon farmed out the app development.
And apparently the packages.xml format has changed since the last time I looked at it, but the app manager lists privileges anyway. VMS.apk has "READ_LOGS" privs along with network connectivity. It could easily rat you out with along with a specific device ID even without root privileges.
Very strange that it would ask for root - it already has quite an extensive set of privileges.
It is a root app
before you root your phone it has root access. Once you root your phone it the application has to ask permission. I accepted mine because I was curious. Nothing happened.

(Q) Anyway to actually fix the bluetooth wake lock?

I was on another stock rom that was giving me some problems with RR's and some things so I flashed another stock T-Mobile debloated rom found here....
http://forum.xda-developers.com/showthread.php?t=2688981
And now I have this hideous BT wakelock. It's really annoying. I have read a lot about it on the net but just not whether or not there is a fix for it... I don't really want to use an AOSP rom. I like the stability of stock with some exposed additives but this is kinda crazy. Really eats a lot of my battery up...
Sent from my LG-D801 using XDA Free mobile app
Try disable service app an try to disable the running service u suspect is running ....?
Sent from my LG-D803 using XDA Free mobile app
deadgiveaway said:
Try disable service app an try to disable the running service u suspect is running ....?
Sent from my LG-D803 using XDA Free mobile app
Click to expand...
Click to collapse
It sounds like you know what you're talking about. I'm just a little confused. Bluetooth isn't running. It's not even turned on. So, I'm not thinking it's an app. Apparently it's a known issue. I just wonder if anyone has fixed it .. Or how their dealing with it.
Sent from my LG-D801 using XDA Free mobile app
It is a bug with in kitkat its self not lg's ui
Download the service disabler app from play store
Open it and go to system apps .. scroll down to bluetooth open it and kill all blue services by clicking them ...
If you end up with any issues with bluetooth not working just revert the diaabled services .
This app works for any serice and is my best friend
Sent from my LG-D803 using XDA Free mobile app
deadgiveaway said:
It is a bug with in kitkat its self not lg's ui
Download the service disabler app from play store
Open it and go to system apps .. scroll down to bluetooth open it and kill all blue services by clicking them ...
If you end up with any issues with bluetooth not working just revert the diaabled services .
This app works for any serice and is my best friend
Sent from my LG-D803 using XDA Free mobile app
Click to expand...
Click to collapse
Thanks! Will do. I hardly ever use bluetooth so this will be great. So I can just re-enable the service when I want to use it! :thumbup:
Sent from my LG-D801 using XDA Free mobile app
Is it even a real wakelock I was under the impression that bug caused it to show as on when it wasn't.
Sent from my LG-D802
treebill said:
Is it even a real wakelock I was under the impression that bug caused it to show as on when it wasn't.
Sent from my LG-D802
Click to expand...
Click to collapse
I dunno. I asked myself the same question. I charged to 100% and then unplugged and went about 16 hours with about 5 hours screen on time before the phone turned itself off.... Others get better life. With the other kit Kat stock rom I had I went about 18 hours with 5 hours screen on time and had about 20% left.... That rom started random rebooting. Never could figure out why... If I reflash it will remove my TWRP hence why I don't just reflash that one and started using this one....
Sent from my LG-D801 using XDA Free mobile app
jcnbama said:
Thanks! Will do. I hardly ever use bluetooth so this will be great. So I can just re-enable the service when I want to use it! :thumbup:
Sent from my LG-D801 using XDA Free mobile app
Click to expand...
Click to collapse
Yes
Sent from my LG-D803 using XDA Free mobile app

Categories

Resources