Detect when a user is in a specific location - java

If I have a restaurant app for example that just orders some food. Is it possible to detect when one of my app users enters the store and then the app does something? For example when the user comes in the app sends a notification or opens up the menu. Also can this be done while the app is neither running on the background nor visually visible?

Related

What accessibility event is triggered when a notification is clicked?

So I have created a chat locking application for Whatsapp such that when user clicks on the locked contact, he/she cannot access the chat without the password or fingerprint. But on clicking the notification of that particular contact's chat, they can access the chat. So to block it, I need to know the accessibility events that get triggered on clicking the notification. I tried getting the events using AccessibilityEvent.TYPES_ALL_MASK , but none of those events have a source and and I cannot get the nodes. Do anyone know any approach to solve this problem?
Thank you.
The behavior may differ on different Android versions.
But when I tried clicking on a notification in the notification tray on a Galaxy S7 running Android 7.0 I got either AccessibilityEvent.TYPE_VIEW_CLICKED or AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED, with package name "com.android.systemui". And if I dumped the view hierarchy starting at the event source I got a FrameLayout containing 3 TextViews.

Clear other apps data programmatically?

I am developing an android application and i need clear the data of another application upon clicking an button.
i.e.: if i click button name "gmail" in my app,the data should be cleared of that "gmail" app
doubt:
1.Is it possible?
2.Do we need to be rooted our android device in order to do this?
° because greenify works with root access to force stop the other app flexibly.
I know that greenify works without root but pop that "force stop" ui screen of each single app to do that action.
MY APP FUNCTIONALITY:
I just wanted to develop an android apllication named "anti-theft cloud apps"
simply if an thief stols our mobile then my app detects when he changes the sim or an unique code send by mobile owner through sms from other mobile and logouts all the cloud based applications like gmail,google photos etc to protect our data to be stolen ,so in order to do that i thought of clearing other apps data(like gmail) PROGTAMITICALLY to logout. Is it possible
This is not possible with stock Android. You can do it with superuser, access root/data/data/PACKAGE and clear its content. But as seen in comment, this seems like evil thing.

How to launch my app programmatically, if an another app opens?

I want my app automatically open when user click (for example) chrome or any other apps.
How to do this?
My app is for preventing people use cell phone all the time.
Explicitly, there is a mission in my app. when user starts this mission, user cannot use other app until they give up the mission.
User can minimize my app, but when user click another app, my app will prompt programmatically to tell user not to use the cell phone.
Instead of preventing user to launch other apps, I think you should use activities' life cycle. You can add code in onPause() and detect user press home button or back button. And when your activity is not on foreground, you can pop a dialog or something to remind your user focus on his work not his phone. BTW I do see the positive side of your app.

Display image on screen while charging on Android

I am writing an Android application that should display the specific image (Bitmap) while the user is charging his phone.
The life-cycle:
User installs my application.
User does not have to run my application.
When user connects the charger (usb to PC or just an charger), my application automatically starts and show the image on the screen (during charging).
User stops charging the phone, my application hides the image.
How could I achieve it?
If i remember correctly you can get the "ACTION_POWER_CONNECTED" event with a BroadcastReceiver to do whatever you want. Just Google, there are pretty good tutorials ;)

Java Android: How to force only one instance of an app (singleTop not working correctly)?

I'm new to Android Java programming.
I've created a simple chat app. Things are going well, but I've hit a small snag. I've set launchMode="singleTop" in my manifest's application tag, and overrided the back button, so now the chat app remains running (in the background) when the user presses the back or home button. I've also created some notifications that pop up in that status bar when a new chat appears (with intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP) set), and when the user clicks the notification it brings the already running chat app to the front. That's all working fine; the problem arises after I bring up the app from the status bar notification, then click back or home, then choose to open the app from the applications menu or a shortcut on the launcher, and thats when it opens up a second instance of the app.
Is that clear?
If the app isn't running and I choose to run it from app menu, it runs (doesn't display any chats because it hasn't received any). I receive a chat and see it on screen in the app, I press back button, I go back and open app through app menu, it runs and has the chat messages from before. Good. Now I press back (so app is in background, but still running), I receive a chat, it pops up a status bar notification, I click it, it opens up the app and shows chat messages from before. Good. Now I click back (so app is running in background). I then open the app through the app menu (like I did the first and second time), but this time it doesn't show the previous chat messages, and if I receive a chat, it makes 2 notification sounds, so I know it has started a new instance of the app.
Any idea what's wrong?
Thanks.
set the activity launchMode to singleInstance in manifest.

Categories

Resources