抵制活动进来前景SCREEN_ON后[Android版] [英] Resist activity to come in Foreground after SCREEN_ON [Android]

查看:84
本文介绍了抵制活动进来前景SCREEN_ON后[Android版]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中,我对SCREEN_OFF做一个功能的Andr​​oid应用。现在,当我再次SCREEN_ON,我看到我的活动再次在前台,我不想来了。我试着在[的onCreate]以及[完成()方法[moveTaskToBack(真)],但两人都没有工作。

I have an android application in which I am doing one function on SCREEN_OFF. Now when I again SCREEN_ON, I see my activity again coming in foreground which I don't want. I tried [finish()] method in [onCreate] as well [moveTaskToBack(true);] but both didn't worked.

您可以认为有服务在后台运行,但是当我们SCREEN_ON主屏幕上还没有出现在前台,直到和Facebook的,除非我们手动不开放的应用程序。

You can think of Facebook having service running in background but when we SCREEN_ON the home screen never comes in foreground until and unless we don't open application manually.

问候

推荐答案

感谢您的帮助了很多奥拉夫。我可以解决这个问题。我告诉你我是如何做的。我把标志的方法,其中我想把

Thanks a lot Olaf for your help. I could resolve the issue. I tell you how i did it. I put a flag in that method where I was wanted to put

 Bundle myKillerBundle = new Bundle();
        myKillerBundle.putInt("kill",1);
        intent.putExtras(myKillerBundle);   

和活动的onCreate,我检查标志

and onCreate of Activity, I am checking that flag

 if(this.getIntent().getExtras().getInt("kill")==1){
            Log.d("ACTIVITY_TAG", "Yes got the flag");
            moveTaskToBack(true);   

现在,每当该标志将是真实的,它会调用该活动,并把它推到背景

Now whenever that flag will be true it will call the activity and push it to background

这篇关于抵制活动进来前景SCREEN_ON后[Android版]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆