简体   繁体   English

将应用发送到后台但不转到首页

[英]send app to background but not go to Home

I want to send app to back form a non-activity class 我想将应用发送回非活动类

With this code ,app send to background but all other apps send to background too 使用此代码,应用程序将发送到后台,但所有其他应用程序也将发送到后台

Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
Home.context.startActivity(i);

I want only this app send to background 希望此应用发送到后台

How to do this? 这个怎么做?

Thanks 谢谢

When you use some global stuff then you need to do some trick by which your application can't affect other applications. 当您使用一些全局性的东西时,您需要做一些技巧,使您的应用程序不影响其他应用程序。

A small technique for your help..Use a KEY for your app and save it inside a SharedPreference . 一种帮助您的小技巧。为您的应用程序使用KEY并将其保存在SharedPreference Use this key to identify your application. 使用此键来标识您的应用程序。 And If the key is perfect then do your code. 如果密钥是完美的,那么请编写代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:当我的应用程序通过单击主页键一段时间后进入后台时,然后重新启动时,该应用程序崩溃了 - Android:When my App go to background by click home key for a while, then when I relaunch,the app is crashed 谷歌家庭将卡发送到谷歌主页应用程序 - Google home to send card to the Google Home app Calabash Android:如何将应用发送到后台(模拟设备/硬件的“主页”按钮)? - Calabash Android: how to send app to the background (simulate device/hardware Home button)? 将应用程序背景设置为与主屏幕壁纸相同 - Set app background to be the same as home screen wallpaper 使用 Firemonkey 将 Android 应用程序发送到后台 - Send Android app to background with Firemonkey 当应用程序处于后台时发送通知 - Send notification when app is background 为什么当我尝试回家活动时应用程序崩溃 - Why the app is crashing when I trying to go to home activity 每次我 go 到主屏幕时,Android 都会杀死我的应用程序 - Android kills my app every time I go to home screen 当应用程序进入后台时片段销毁 - Fragment Destroy when app go in background 应用程序在后台时如何去参加活动? - How to go to an activity when app is in background?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM