How use SYSTEM_ALERT_WINDOW with ionic v6 Cordova - android

I have implemented the permission for use SYSTEM_ALERT_WINDOW (pop-up window) with permission accepted but I don’t know how use or how show the pop-up window for Android.
I want show pop-up or open the application when is in mode background.
I try with notification push with the property force-start: 1 but not results success, also I try with background mode but I don’t know how show popup
Any help Thanks

You have to add the cordova background mode (if you are using Cordova) for that purpose.
https://github.com/katzer/cordova-plugin-background-mode
When a notification arrives, you just move to foreground your application (all the documentation is on github).
It should work with the permission you've already granted.
Take into account that you better move your app to the back when the task you are performing finishes

Related

AppState changes to background in android

I have integrated some code to handle a logic when the app is changing from foreground to background and vice versa. When the user navigates to the home screen we are requesting some permissions for location, camera and stuff from the user. The issue is in Android, in which when permission popups in the screen, app state changes to background, but I want the actual foreground -> background functionality to be triggered. I have used AppState in react native to achieve this functionality. It would be a great help if one can elaborate why the app is going to background when permission confirmation alerts popups? Thanks in advance.
Flag the permission like whenever you are gonna ask permission make isPermissionAsk to true. and in AppState Listener - for callback function where you are doing you stuff add a check on top
if(isPermissionAsk)
{ changePermissionAsk(false); return;}
In Android or iOS the permissions are OS managed features and the doesn't have any control other than requesting permission or getting state of permission. So when a permission is required you can think of permission app is in foreground which puts your app in background.

Start Activity from WorkManager API Level 29+

We can't start activity from Work Manager according to the new Restrictions If App doesn't meet the requirements. All i want is to start activity from Work Manager even application is killed or no longer visible after some specific time. I do not want to run the App in foreground. Is there anyway, I can achieve this?
Any help would be appreciated.
If you have in house App or for testing, You can use this approach.
Add this permission in Menifest.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Also go to the App info settings
Setting -> Advanced -> Display over other apps
Allow this permission for this app. Now run the app, This will be able to start the activity from background.
But, I recommend to show notification and open the screen on tap notification.
You shouldn't start activities from background since it interrupts user's work.
If you want to open your app from work manager, you'll have to use notifications instead and set the notification tap action to open your specific activity using pending intents.
Here is a guide on how to create a notification in android.
Additionally, if your app needs to do something urgently, you can create a high priority notification, details here

Android Q background restrictions

I need to show an activity on push received, but I am getting Background activity start from package-name blocked. system Toast.
This is an authentication activity where user needs to perform some task. I do not manage phone or NFC interaction thus I don't need to actually start 'special' service but showing notification is not enough - I need that activity.
SYSTEM_ALERT_WINDOW permission doesn't help.
So, should I re-implement all my flows to work only with notifications? Is there any possibility to start activity when application was closed (No activity in back stack)?
Android Q places restrictions on when apps can start activities. This behavior change helps minimize interruptions for the user and keeps the user more in control of what's shown on their screen.You can see the full document here
As of Android Q Beta 4, this change has the following properties:
Affects your app if you launch activities without user interaction
Mitigate by using notification-triggered activities
Disable restrictions by turning on the Allow background activity starts developer option

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

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

Categories

Resources