开发者

Android minimize application

开发者 https://www.devze.com 2023-02-03 22:49 出处:网络
I have developed one application. I want this application to work in background (minimize the 开发者_JS百科application on button click). When user clicks on button the application should minimize and

I have developed one application. I want this application to work in background (minimize the 开发者_JS百科application on button click). When user clicks on button the application should minimize and should run in background. How do I accomplish this?


You should review the android Activity lifecycle. If your app is not in the foreground then it can be stopped by the OS at any time.

If you want to perform background processing decoupled from your UI you should consider a service.


You can minimize your application putting it to background.

It can be done starting an Intent that takes you to home screen.

Look how to do that in this post: How to minimize whole application in android?


You can minimize your application by sending it to the background with:

moveTaskToBack(true);

or start your android home screen with something like this:

Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
this.startActivity(i);
0

精彩评论

暂无评论...
验证码 换一张
取 消