startActivity(intent)它没有工作?当我的DemoActivity使用android:launchMode =" singleTask"时,

时间:2015-11-20 07:06:59

标签: android android-intent start-activity

这是我的AndroidManifest.xml

<activity android:name=".ui.activity.ERPWebContainerActivity"
          android:launchMode="singleTask"
          android:screenOrientation="portrait"
          android:theme="@style/Theme.Eallcn.Fullscreen">
</activity>

当我进入新的Demo1Activity时,我会处理一些数据,从Demo2activity步入Demo1Activity。 当我参加Demo2activity活动。我使用这种方法:startActivity()无效。

Intent intent = new Intent(this, ERPWebContainerActivity.class);
intent.putExtra("waitUploadImageLists", waitUploadImageLists);
startActivity(intent);
finish();

3 个答案:

答案 0 :(得分:1)

您可以使用几乎相同的.data str: .asciiz "abc" coma: .asciiz ", " .text main: la $a0, str li $a1, 0 jal perm li $v0, 10 syscall length: lb $t0, 0($a0) beq $t0, $0, preperm addi $v0, $v0, 1 addi $a0, $a0, 1 j length preperm: subu $a0, $a0, $v0 jr $ra perm: subu $sp, $sp, 32 sw $ra, 0($sp) #salvo ra sw $a0, 4($sp) #salvo cad sw $a1, 8($sp) #salvo L jal length sw $v0, 12($sp) #salvo n subu $v0, $v0, $v0 lw $a0, 4($sp) #rescato cad lw $a1, 8($sp) #rescato L lw $t0, 12($sp) #rescato n li $t2, 0 #$t2=i=0 for1: sub $t1, $t0, $a1 # $t1= n- L bge $t2, $t1, fin1 # i >= n- L => fin1 li $t3, 2 # $t3=2 (constante) bgt $t1, $t3, recursion #n-L >2 => recursion mostrar: li $v0, 4 syscall la $a0, coma syscall subu $v0, $v0, $v0 jal nomostrar recursion: sw $t2, 16($sp) #salvo i addi $a1, $a1, 1 #l++ jal perm #recurso nomostrar: lw $a0, 4($sp) #rescato cad lw $a1, 8($sp) #rescato L lw $t0, 12($sp) #rescato n lw $t2, 16($sp) #rescato i add $t4, $a0, $a1 #$t4 = direccion cad[L] lb $t5, 0($t4) #$t5=cad[L] add $t6, $a0, $a1 add $t6, $t6, $t2 addi $t6, $t6, 1 #$t6=direccion cad [L+i+1] lb $t7, 0($t6) #$t7 = cad [L+i+1] sb $t7, 0($t4) sb $t5, 0($t6) #swap (cad[L],cad [L+i+1]) add $t7, $a1, $t2 #$t7 = L+i subu $t5, $t0, 1 #$t5 = n-1 bne $t7, $t5, cola #L+i != n-1 => cola or $t8, $a1, $0 #t8= j = L for2: bge $t8, $t0, cola # j >= n => cola add $t5, $a0, $t8 #$t5 = dirección de cad[j] addi $t1, $t5,1 #$t1 = dirección de cad[j+1] lb $t7, 0($t1) #$t7 = cad[j+1] propiamente dicho sb $t7, 0($t5) # cad[ j ] = cad[j+1] addi $t8, $t8, 1 # j++ j for2 # repetir cola: add $t8, $a0, $t0 #$t8 = dirección de cad[n] sb $0, 0($t8) # cad[n] = '\0' addi $t2, $t2, 1 # i++ sw $t2, 16($sp) j for1 # repetir fin1: lw $ra, 0($sp) #rescato ra sw $0, 16($sp) addi $sp, $sp,32 #libero memoria jr $ra #retorno 。 但是如果您的要求是仅使用android:launchMode="singleInstance",那么您可以这样使用它:

机器人:launchMode = “singleInstance”

每当调用您的活动意图时,只需删除singleTask并设置launchMode="singleTask"标记

答案 1 :(得分:1)

enter image description here

您可以覆盖此方法,您可以获取Intent数据! 为什么?因为活动没有完成,当我从StartActivity形成Demo2activit时,它没有进入onCreate方法!

你可以获得重新获得的方式:你可以看到Android:lunchMode

enter link description here

enter image description here

答案 2 :(得分:0)

尝试这个顺序。

finish();
Intent intent = new Intent(/*intent parameters, but as I can't copy and paste it from a picture then... */);
startActivity(intent);