在kotlin中结合旗帜并清除痕迹

时间:2017-09-05 06:29:18

标签: android android-activity kotlin backtrace

我正在使用kotlin来开发android应用程序。在Android中,我们使用addFlags和setFlags来设置标志并清除由" |"分隔的后跟踪活动。如何在Kotlin实现它?我目前在Kotlin中使用以下代码:

startActivity(Intent(context, MyActivity::class.java)
            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK))

但它不起作用。我也试过addFlags,它也没用。在这种情况下应该做些什么?

5 个答案:

答案 0 :(得分:6)

像这样使用

@Echo off

Echo Starting the script for copying files to other folder.

set dt=%date:~10,4%-%date:~4,2%-%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%

set filesMovedCount=0

forfiles /p C:\symphonybackup\symphonybackup\Symphony\SymphonyArcheive /s /m *.* /d -30 /c "cmd /c echo @path >> C:\symphonybackup\symphonybackup\Symphony\%dt%.log & cmd /c copy @path C:\symphonybackup\symphonybackup\Symphony\SymphonyTemp" 

Echo filesmovedcount:%filesMovedCount%

Echo finised copying the files

答案 1 :(得分:1)

故意使用此选项以清除回溯活动

var intent = Intent(this, [Your_activity]:class.java)
    intent.flags =  Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
    startActivity(intent)

答案 2 :(得分:0)

<maven.compiler.release>11</maven.compiler.release>

添加到清单val intent = Intent(this, MyActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK startActivity(intent)

答案 3 :(得分:0)

有意地使用它以清除回溯活动

  

Java

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
  

科特林

 var intent = Intent(this, [Your_activity]:class.java)
        intent.flags =  Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
        startActivity(intent)

答案 4 :(得分:0)

 val intent = Intent(activity!!, MainActivity::class.java)
    startActivity(intent)
    activity!!.finishAffinity()