Background process stops when another page is open in phonegap android - android

I am trying to create an app in which i am using background serviced plugin for uploading data to server.Then i tried to go back to the app home page when a background service will start so the user can do other work while data is uploaded. but the issue is as soon as I click on the device back button it gives an network not found error and background service stops and it navigate to another page. Then i search how to navigate to device main page using device back button using home plugin know after starting the background service when i click on the back button it opens the device home-screen and the backgroung process continues. Can anyone tell me how to make an background serviced continue and navigate to another page.

Related

flutter app create new instance when app resume

I am working on a meet app with Jitsi meet in a flutter. it has two screens the first screen takes all the meeting details and the second screen is the meeting screen. The app has a picture in picture mode I turn off the pip mode.
When a meeting is ongoing I press the home button meeting is getting minimized (ongoing in the background) when I click on the app it does not take me back to the meeting instead it creates a new instance of the app on top of the background process this happens only the first time after installation on the app.
When I restart the app above issue is not anymore occurring (opening the app for a second time). for the second time When the app is minimized if I click on the app, it takes me back to the meeting.
Please help anyone know what is happing.
Picture in Picture is Disabled in the latest changes.
still the same issue.
You must use Services for fix app in foreground for first step.
Then, You can set it to what happen when user click on picture, in this way u can manage call in background and also sent him back to call screen like open a notification.
Example :
you receive a notification from some app, when u click on it, u will go to page what developer want.
I hope you get it, update me in comments.

Overlay my application on top of other app and close the app

I am trying to create an app that works on the same lines as app lockers, what i've achieved till now is when you open one of the predefined apps it opens up my app on top of it, but pressing back loads back the app that is supposed to be blocked! This is the code I am using, I don't expect it to work but I don't know how to achieve what I need
//If Application is open (this is done and works)
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("myapp.package.name");
startActivity(launchIntent);
To reiterate,
1) My app opens when the predefined app is open
2) Pressing back button closes my app and loads back the blocked app
3) I don't want the blocked app to be accessible

How to bring an application to front of another one which is currently running?

I Have an android application in which I handled the device Home button click.I made the application relaunched automatically when user clicks on Home button while my application is running using Service.
When user clicks on Home button while running my application , shows default home screen and then shows again the activity.
But my problem is that is takes some long time to show last activity of my application from home screen.ie,the home screen is displayed for a long time.Because of this user can launch any other application from home screen and my application runs in background.ie,When pressing BACk button after launching another application it is possible to view my application.
Is it possible to avoid this delay and bring my application to front of that launched app?
Thanks in Advance
Place the Home button Code in your AsyncTask doinBackground() or you can use Handler. That would help you in reducing the delay of loading the activity. For more information on How to use AsyncTask and Handler, check this link: Android Background Processing
I implement a countdown timer in my service that repeatedly start my activity in onStick. When my activity comes to the foreground, in onNewIntent I send a message to the service to cancel the countdown timer. It works out pretty well.

re-lunching an android app from list of recent apps vs pressing on the app icon

I have written an Android app that plays some audio. There is a stop button on the app GUI that when I first lunch the app works fine.
However when I go out of the app while audio is playing and come back depending on how I came back the STOP button works or not.
If I come back to the app by holding the home button and seeing the list of recent apps and choosing my app from there, then the STOP button works. But if I click on the app luncher icon the STOP button does not work.
What is the difference between these two method and how can I make the re-lunch of the app by pressing on the app icon to behave similar to when I re-lunch the app by choosing the app from the list of recent lunched apps.
Without seeing the code we can't be entirely sure, but it sounds like what is happening is that your activity is you set up an action listener (setOnClickListener) on your stop button in your onCreate() method.
The onCreate() doesn't get called again if the app is never recycled (Android will do this when your app is put into the background) and started over.
When your app is put into the background onPause() will get called, then coming back from that you will get a call to onResume(). If your app has been in the background longer or Android needed more resources you'll get a call to onStop hitting the home button and onStart when the app opens again.
You'll need to do some investigation into your code as to why your listener goes away, but now you have the hooks to make sure they are connected back up when you're app is back.

Using home button on android phone

In iphone when we exit app and start app again by clicking launcher icon the app start from screen which was open last time before exiting app.
We can achieve same in android when we exit app using center or home button on android phone. In android app if app is exited by pressing home button and started again by clicking on launcher icon the app start from activity which was open last time before exiting app.
Is that functionality similar to iphone in terms of keeping app in memory longer? Will that work in android all time because I think android system will remove app from memory after sometime or will it remain in memory longer? Can I depend on this functionality in android and expect it to work all time.
I have a project in android which client has asked me to have iphone like functionality if we exit app and start app again it should open from screen which was opened last time before exiting. Now this is possible in android only if we use centre button. And also if user has exited using centre button and started it again, app should check for user current location and do some other operations. If app is launched and user navigate to any activity is there any way to check if app was exited using back button or centre button so that I can run code if app is exited using center button.
Thanks
We can achieve same in android when we exit app using center or home button on android phone.
The HOME button does not "exit app".
The HOME button brings the home screen to the foreground, just as the CAMERA button (where available) brings the camera application to the foreground, the CALL button (where available) brings the dialer to the foreground, tapping on a Notification may bring something else to the foreground (e.g., SMS client) based on the Notification, etc.
In android app if app is exited by pressing home button and started again by clicking on launcher icon the app start from activity which was open last time before exiting app.
No. If you tap on a launcher icon, and the app's process is still in memory, the existing app instance will be brought to the foreground, returning you to whatever activity you had been on. If you tap on a launcher icon, and the app's process had been terminated to free up RAM for other apps, you launch a fresh copy of the app and bring up whatever the ACTION_MAIN/CATEGORY_LAUNCHER activity was that the user tapped upon.
Will that work in android all time because I think android system will remove app from memory after sometime or will it remain in memory longer?
The length of time that a non-foreground app's process will be in memory is indeterminate and will be based on what is going on with the device, plus the device capabilities (e.g., how much RAM). I suggest you read more about the process lifecycle.
Now this is possible in android only if we use centre button.
It is not possible "if we use centre button" (what Android developers refer to as the HOME button). It may happen automatically, but if the app's process has been terminated, it will not happen automatically.
If app is launched and user navigate to any activity is there any way to check if app was exited using back button or centre button so that I can run code if app is exited using center button.
You should not care whether the "app was exited using back button or centre button".
You should care whether you have your data and how old that data is, refreshing it if it is stale.
Whether the user left your app via HOME, BACK, CAMERA, CALL, a Notification, the recent tasks list, an incoming phone call, by smashing their phone to bits with a rock and replacing it with an exact duplicate, or by any other means, should not matter to you.
To draw an analogy, think of a Web app. In a Web app, you care about whether you have a session cookie and whether that session is stale (e.g., to force a fresh login). Whether the page request came because the user clicked a link within the app, or clicked on a link from a third party site pointing to your app, or refreshed their page, or used a bookmark to get at another page in your app, or double-clicked on a desktop icon that brings up your app, or right-clicked on a link and opened a fresh tab, or anything else, should not matter to you.
Review the Android Activity Lifecycle at http://developer.android.com/reference/android/app/Activity.html. If you do nothing, you have no guarantee of your app starting at the same point it left off, however you have control here. You can, for example, overload the onPause() method to save your state to a file, and onResume() to restore it.

Categories

Resources