Android启动preSS家在发射进入默认屏幕 [英] Android launcher press home in launcher to go to default screen
问题描述
在默认的Android启动,pressing家,而在另一个活动将开始启动。 pressing回家了,而在发射器将重置为默认主屏幕页面。我不知道如何可以做到这一点。机器人发送相同的意图启动器是否在前台或没有。 Home键也无法由用户的应用程序被截获。
有没有办法来实现这一目标?
Android的发送相同的意图发射器是否在前台与否。
块引用>正确的。
Home键也无法由用户的应用程序被截获。
块引用>正确的。
我不知道如何可以做到这一点。
块引用>如果一个呼叫
startActivity()
将导致意图
被传递到活动的现有实例,则不会创建一个新的实例(定义)和现有实例被称为与onNewIntent()
而不是的onCreate()
。在主屏幕,一般的活动,真正的是的主屏幕将使用
的android的情况:launchMode =singleTask
或的android:在launchMode =singleInstance
清单,如:<活动
机器人:名字=启动器
机器人:launchMode =singleTask
机器人:clearTaskOnLaunch =真
机器人:stateNotNeeded =真
机器人:主题=@风格/主题
机器人:screenOrientation =nosensor
机器人:windowSoftInputMode =stateUnspecified | adjustPan>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.HOME/>
<类机器人:名字=android.intent.category.DEFAULT/>
<类机器人:名字=android.intent.category.MONKEY/>
&所述; /意图滤光器>
< /活性GT;(从在AOSP 老发射器)
然后,该活动可以实现
onNewIntent()
做一些事情。在上述旧发射器的情况下,<一href=\"https://github.com/android/platform_packages_apps_launcher/blob/master/src/com/android/launcher/Launcher.java\">itsonNewIntent()
包括:如果(!mWorkspace.isDefaultScreenShowing()){
mWorkspace.moveToDefaultScreen();
}本,presumably,动画用户界面返回到默认屏幕如果用户是presently查看该组由主屏幕活动管理屏幕内的一些其它屏幕。
另一种方法来触发
onNewIntent()
,而不是使用的android:launchMode
,是做选择的时候你叫startActivity()
,通过在适当参数的意图
,如FLAG_ACTIVITY_REORDER_TO_FRONT
。In the default android launcher, pressing home while in another activity will start the launcher. Pressing home again while in the launcher will reset to the default home screen page. I don't understand how this can be done. Android sends the same intent whether the launcher is in the foreground or not. Home key also cannot be intercepted by user apps.
Is there a way to achieve this?
解决方案Android sends the same intent whether the launcher is in the foreground or not.
Correct.
Home key also cannot be intercepted by user apps.
Correct.
I don't understand how this can be done.
If a call to
startActivity()
will result in theIntent
being delivered to an existing instance of the activity, a new instance is not created (by definition) and the existing instance is called withonNewIntent()
instead ofonCreate()
.In the case of a home screen, typically the activity that truly is the home screen will use
android:launchMode="singleTask"
orandroid:launchMode="singleInstance"
in the manifest, such as:<activity android:name="Launcher" android:launchMode="singleTask" android:clearTaskOnLaunch="true" android:stateNotNeeded="true" android:theme="@style/Theme" android:screenOrientation="nosensor" android:windowSoftInputMode="stateUnspecified|adjustPan"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME"/> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.MONKEY" /> </intent-filter> </activity>
(from an old launcher in the AOSP)
Then, the activity can implement
onNewIntent()
to do something. In the case of the aforementioned old launcher, itsonNewIntent()
includes:if (!mWorkspace.isDefaultScreenShowing()) { mWorkspace.moveToDefaultScreen(); }
This, presumably, animates the UI back to the default screen if the user is presently viewing some other screen within the set of screens managed by the home screen activity.
Another approach to trigger
onNewIntent()
, instead of usingandroid:launchMode
, is to do it selectively when you callstartActivity()
, by including appropriate flags in theIntent
, such asFLAG_ACTIVITY_REORDER_TO_FRONT
.这篇关于Android启动preSS家在发射进入默认屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!