How to kill chat-heads like app form other app programmatically? - android

I'm writing an application managing access to other applications. User can decide which app he would like to block on device, If someone start blocked app he see screen informing him about blockade. I have my own launcher and background process which check if currently open activity is blocked one. To check top activity I use package and class name from ActivityManager getRunningTasks(); If this app is blocked I cover it with my own View by adding it to WindowManager. This works for every app, except this which also use WindowManager like facebook chat heads or multitasking brought by LG - QSLIDE. This application isn't on top. Of course I can find her process using getRunningAppProcesses, but I cant kill it. Android.os.Process.killprocess don't work also. I know this is not a good idea but I don't have other one.
Is there a possibility to recognize that some app added something to WindowManager and eventually block it? Or just remove view or kill the app?

Facebook (and many other apps) draw to the Window with SYSTEM_ALERT to manage their little chat heads. As of writing this (6.0.1) there is no API to listen for views being added and/or gather any information about that view.

Related

How to code an app that blocks other apps from launching for a certain time using Android Studio

I want to code an app that hinders other app from launching. Can someone please help to start from the beginning. Can someone provide an example and i'll try my best to understand it. Thanks (Full code if possible :D)
One example is AppBlock in the play store.
To create a feature that 'blocks' other apps from running like AppBlock, you simply just need to show a popup on top of the other apps.
Look into SYSTEM_ALERT_WINDOW, with this, you can draw on top of any other app.
Once you have that working, you should look into the other permissions of AppBlock,as it'll show you what they're doing.
AppBlock's Permissions
bind to an accessibility service
update component usage statistics
receive data from Internet
view network connections
full network access
run at startup
reorder running apps
control vibration
prevent device from sleeping

Android: launch any activity to start in the background?

If I'm writing my own Android app, I know how to structure it as a Service so it will start running in the background.
However, is there a way to launch an existing app (for example, any random .apk from the Play Store) so that it starts up in the background, without its screen taking over the display?
Alternatively, I'd be willing to launch the app, force it into the background, and redisplay the window of the previous app (whatever it might have been) that was running in the foreground. I don't know how to programmatically put the current app in the background and then determine the previous app and bring it back to the foreground.
I'm willing to do this any way possible: via Java, via one or more command-line utilities, via a Tasker plugin, via an Xposed module, or whatever.
Thank you in advance for any pointers to docs or any suggestions.
I discovered that the #0 entry of "dumpsys activity recents" gives the currently displayed activity ... at least on my rooted Marshmallow device. This gives me what I need.

How to make an Android app running all the time

I am makin an android application on Emergency communication.I want my application should run all the time and whenever it needs it should be able to run.I want that user should not be able to close it by any means.Like Google Maps application which is restarted again on killing its all activities and even we force close it,it will be restarted.
Seems you are learning app development ... but this is not the way you should pose question here... you should post what you have done and code issues and not ask for an entire class...
But i will try to answer your question are you trying to create an app which when started wont be able to be closed and come back to home screen ???!!!!!
See you are creating an app which will run on android operating system which is similar to linux so you must follow the Activity
LifeCycle
I remember i created an app where there were shortcuts on screen so using that i was directing the user to specific links but you can use for calling etc.. i donno if that is what you are searching for...
You might create a notification bar if you want which cannot be cancelled and you can place the code in the intent which will be called from this...
Also services are there which u can utilized what other users have suggested...
thx
You could use an extra service running in the foreground, but there will be always a notification of this service in the notification bar.
See here: http://developer.android.com/guide/components/services.html#Foreground

How to kill an app with the hard buttons in Android Smartphone?

In iOS device, we can kill a foreground app with the hard buttons. We can do it by the way written below:
1. Push down the power button and keep pushing
2. Wait for the power-off screen is shown
3. Push the Home button and keep pushing.
If we use this way, the data of the foreground app that is not saved will go away.
Usuually we only use this method when our device freezed, but some game players around me use it for other purpose.
But I dont know the same method in Android.
Do you know the method to kill the foreground app with the hard button, and without running onPause()?
If you know, could you tell me it?
*I am a (private) junior high school student in Japan. I think I am better at using English than public school students, but there may be some grammer mistakes, wrong collocation, or spelling mistakes. So please read carefully.
Any answers or hints will be thanked.
I'm waiting for your good answers or hints!
If you mean killing an application screen progrmatically use -
finish();
once you leave the activity for another screen, if you mean physically (using the device physical buttons) than a long push on the home button will show you all the apps running on the foreground swipe them to the left or to the right in order to terminate them
However some apps uses services in order to fetch data or make logic operations which are unbound to the UI for those you should go to the "Application manager" on your device setting and kill them manually (by pressing stop) you can also use this app.

Launch one activity from another

i just want to know how can i detect if the user opens an app so an activity of mine launches as well.
For example, the user opens the sms app and right after a kind of lockscreen appears.
You can create a service which will run int the background and you can use this API to determine which activity is visible. That's how many app lock works.
As far as I understand the Android system, it is not possible unless you are making a custom firmware.

Categories

Resources