与REORDER_TO_FRONT令人费解的行为 [英] Puzzling behavior with REORDER_TO_FRONT

查看:181
本文介绍了与REORDER_TO_FRONT令人费解的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

活动A开始b活动,没有标志。堆栈现在在顶部B A-B。 B开始与FLAG_ACTIVITY_REORDER_TO_FRONT(唯一的标志)活性的。我希望堆栈现在是B-A。然而,当后退按钮是pssed在这一点上它返回到主屏幕$ P $。在这里,我希望b活动被带到前面。当再次点击启动器图标,该应用打开与乙作为堆栈中运行的活动并没有什么。

Activity A starts activity B with no flags. The stack is now A-B with B on top. B starts activity A with FLAG_ACTIVITY_REORDER_TO_FRONT (the only flag). I would expect the stack to now be B-A. However, when the back button is pressed at this point it returns to the home screen. Here I would expect Activity B to be brought to the front. Upon clicking on the launcher icon again, the app opens with B as the running activity and nothing in the stack.

Launchmode是标准清单(默认值)。

Launchmode is standard (default) in the manifest.

这是预期的行为,我只是不理解它是正确的?

Is this the expected behavior and I'm just not understanding it properly?

编辑:我创建了一个测试项目,没有混杂因素,仍然可以看到相同的行为。我只是不明白它,它似乎并没有为每文档。

I have created a test project with no confounding factors and still see the same behavior. I just don't understand it, it doesn't seem to be per the documentation.

编辑:对我来说,这种行为似乎是在框架中的BUG,请参阅我下面的回答评论。我需要一个解决办法。

To me this behavior seems to be a BUG in the framework, see my comment on answer below. I need a workaround.


public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
public void onClickBtn(View view)
{
    Intent flowIntent = new Intent(this, SecondActivity.class);
    startActivity(flowIntent);
}

}

公共类SecondActivity扩展活动 {     @覆盖     保护无效的onCreate(包savedInstanceState)     {         super.onCreate(savedInstanceState);         的setContentView(R.layout.activity_second);     }

public class SecondActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); }

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
public void onClickBtn(View view)
{
    Intent flowIntent = new Intent(this, MainActivity.class);
    flowIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(flowIntent);

}

}

清单:

Manifest:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android&quot;
    package="com.example.tester"
    android:versionCode="1"
    android:versionName="1.0" >
 <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.tester.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
         <activity
            android:name="com.example.tester.SecondActivity" />
    </application>
</manifest>

推荐答案

<一个href="http://$c$c.google.com/p/android/issues/detail?id=63570#c2">http://$c$c.google.com/p/android/issues/detail?id=63570#c2

它已被证实由谷歌作为4.4.2错误

it had been confirmed by google as a bug on 4.4.2

这篇关于与REORDER_TO_FRONT令人费解的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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