How to stop/pause an activity in watch from mobile? - android

I am currently starting an activity in watch from mobile by clicking a button. I am using wearable listener service to do it. Once the activity is started, the user performs gestures which are recognized and sent to mobile. So at some point in time, I want the user to click a button in mobile to close/pause this activity in watch. How can I do it? Should I destroy it or pause it? What should be my approach? Please advise

When you receive the message telling to close app in watch from phone,you can cancel all running work and close all activities in watch app or call System.exit(0).

Related

Can I do anything before the user closes the application?

My application flies drones through missions and I want to stop the drone mission when the user closes the application, I have tried with onDestroy(), onTaskRemoved() in a service, onBackPressed() and with onTerminate() in the Application class, but none of this works, so I started to wonder if it is possible to do what I want to do, thanks in advance.
For example when I click the switch app button, I mean the left button on this image and then click on close all or slide the app to close it, that way of closing the app is what I'm referring to.

Close app when minimized

I have similar problem like this.
On start my app displays a splash screen and checks via network if the current user is still premium.
My problem: I started my app right before I went to bed and minimized it by pressing the home button. In the morning I launched the app again and it resumed the activity from the night. The app never really quit, my splash screen was not shown and and it couldn't check if the user is still premium.
So how can I achieve my app to be closed after a certain time (e.g. when the app is minimized)?
But the problem is there is a portion in the app where I can view videos in full screen and here I use android's default player. So when the app is minimized while watching and then again open the app onResume will not be called and cannot check whether it is a registered user or not. The video player will continue to play the video. Is there any method so that I can kill the app when the video is playing and minimised?? is there any method which is called when the app is minimised using home key press?? Is it possible in every device to detect the home keypress event and write some code there?? Please help with some fresh ideas!!!
Now I know why my reputation is always low. Thanks Dan Hulme. You are right I just want to use the app lifecycle correctly. I want to use onRestart not onResume. And that have done the work for me. Thanks all.

Launch android app after start and block other apps

I'm facing the following problem. I want to make an android device to run only my application. All other apps and phone feautes should not be available to a user.
The reason why I want to achieve this is simple: I want to destribute devices with preinstalled application to my client but I don't want to let them use all phone featues.
This could work this way: just after android boots my application is launched automatically and than somehow all other staff is blocked.
Do you have any suggestions how to achieve that? Is it possible? Do I need to root a device?
I hope you get my problem. Any advice you can give will be greatly appreciated.
This is a bit crude way. But see if it is of any help.
If you create your application as a launcher it will start on boot(using system broadcast BOOT_COMPLETED).
Then you need to override all the three android buttons Home, back and recent apps.
To override back button you just have to override the onBackPressed() method.
For home button you will start a service which will run in background. This service will check if your app is in foreground or not. if not then it will bring it in foreground. so when the user presses home the service will sense the foreground app isnt yours and launch it.
But for this switching back of your app android takes approx 3 to 5sec. In that period of time you can display a warning text which will block the user from stopping the service from settings.Also if you remove the activity animations then it will appear seamless.
For recent apps button the above trick will do. If the user tries to close the app using this button your background service will sense it and launch your app.
so its the background service that does all the trick. if you some how stop the service or uninstall the app you are through :p

How to restart service on power button or at the same time if it is forced close by user using task manager?

I am facing a big issue in android service and I searched more than 3 days but I didn't get any solution so please help me.
Currently I am working on a lock screen based service project that make your phone more secure means no one unlock it easily that's work fine but the main problem is that if my application is forced close by user via task manager then it also force close the service of my app then after that, when user press lock button to unlock his phone then it directly open home screen.
Is there any way to restart my application service after few second or at the same time or at the time is user press power button.
In my app I am also disable default lock screen that,s why if my app is force close then after that no security is worked for phone it directly show home screen that's not good, if my app is forced close then at least it enable default lock screen.
Any one who have idea about this please help.
Thanks in advance.
In Android, it's usually not recommended to start the service on it's own even if it is explicitly killed by the user. I don't think if there is a way to start the service again if the user goes into settings and kills it. BTW did you specify the service as remote?

Android (notifications) - C++ Code turns on bluetooth - but no notification is shown in Notification Bar

Hey Guys.
I'm working with a collegue on a android app. At some point the app starts Bluetooth by itself without user interaction. This is written in C++. Now I want to turn the main Bluetooth Symbol on, to inform the user that Bluetooth is turned on.The same for WiFi.
I could create my own notifications, but that's not what I want.
How can I access the main notification symbols in Java?
Another question about notifications:
I have a notification for my main app. Every time I click on the notification the app is restarted (onCreate is called). When I click the Home Button, when my app is in the front is shows the home screen and by clicking on the app symbol it resumes the app (onResume is called). I want exactly the same behaviour when I click on the notification. How do I achieve this?
thanks in advance
Afaik, this works only if you call it from Java, or call into corresponding Java methods via JNI, which will update the proper notifications for you.

Categories

Resources