Always run App in background Programmatically- AIDE


 Hi Guys welcome back my new android programing post in this post i will show you How to get background running application in android programmatically and make background running app in android also

in this post, we will see how we can create an application that can be run continuously in background, can such an application be made the help of programming, i will tell you all complete detail in this post,



why running apps in background

any applications runs in the background so that it can continue to provide service to you on your android mobile, you must have seen on mobile that many applications like sms, calling applications are all run in the background on your mobile,

even if you want to stop these applications from the background, you cannot stop it in android mobile because these are the main system function of android mobile, if you stop then SMS will not come on your mobile, if someone calls you, you won't be able to call, so that's why you can't stop these applications from the background.

why developers make their application running background

the developers therefore makes his application background running, so that he can provide the service of his application to you properly and always,

any company making an application wants to run its application in the background on mobile, so that their designed application can run on mobile for a long time and the user does not face any problem.

why application can't run in background on Android Oreo

earlier, when developers to make android applications, when they did not have such a problem to background running, but after released Android version 8, the developers have got the problem to make the application in the background running,

apart from this, there is a third party UI in many android mobiles, which also stops the application in background running. this third party ui stops the applications from the background so that the mobile battery can run more.

how to keep the application in the background on android

in all the mobiles above Android version 8, if you want to keep an application in the background, then you have to run some such service in the background, 

to do a background application, you can apply the application in the background to some service that can keep the application persistent on android mobile.

apart from this, you can also add in to the whitelist so that the battery optimization does not stop it.

how to stop apps running in background

to stop the applications from the background, you get a lot of options on mobile, but note that you can stop some application from the background running, you cannot stop every application from the background on mobile.

the first way to stop the application is that you go to the application manager and stop the application, for this you have to open mobile settings, then you have to go to app management, from here you have to click which application you want to stop and the option comes, then you have to click force stop button so that the application stop on the background.

the second way is to stop the application, you have to open mobile settings, then you have to go to the developer option, here you will get an option of running service click on it, in this you see which application is in  running your background process, now click on the application that you want to stop the background and click on the stop button that will stop application from your mobile

ok now let's move to the practical way that with the help of programming we can do the application in the whitelist and background running.

Step-1

First of all, you have to import the source code of any application inside Android Studio or AIDE application, iam currently going to make a background running application in android using the Aide application.

Step-2

After importing the application, you have to open the MainActivity file, you have to follow this process in all application, 

Step-3

Now you have to first import Android Requirement java function into it, with the help of which we can create background service app for android here.

 
import android.content.Intent;  
 import android.os.PowerManager;  
 import android.net.Uri;  
 import android.os.Build;  
 import android.provider.Settings;  
 

Step-4

How to make an android app to always run in background

Now you have to paste this code just below the application launch activity, with the help of this application always running background 

in the image below, you see where i have pasted this code, if you paste from wrong place, your application will not build or will crash.


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {  
   Intent intent = new Intent();  
   String packageName = getPackageName();  
   PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);  
   if (!pm.isIgnoringBatteryOptimizations(packageName)) {  
     intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);  
     intent.setData(Uri.parse("package:" + packageName));  
     startActivity(intent);  
   }  
 }  
 

Step-5

How to run background service continuously in android 

Now you have to add the permission of Battery optimization to the AndroidManifest file of the application

 <uses-permission   
 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/> 
 

Step-6

How to keep an app running in the background android programmatically

Now you have to allow the application whitelist permission, which will allow the app to run continuously in the background.

Conclusion


this post is a conclusion of how we can create an application that runs in the background on mobile, how can run the application in the background with the help of programming. 

and how developers can run their application in the backround continuously, also i have told you how can stop any application from background on your mobile
so i hope you like this post and i will see you in the next post Thanks and Take Care.


Post a Comment

0 Comments