V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
nnegier
V2EX  ›  Android

Android Activity Intent 被清空?

  •  
  •   nnegier · Apr 26, 2023 · 10870 views
    This topic created in 1097 days ago, the information mentioned may be changed or developed.

    我原有代码有一处显示启动 Activity 并传递信息,今日复查发现启动目标 Activity 后传递的信息却消失了获取不到这一 bug ,不明所以,特来求教。

    启动代码如下:

    Intent intentNewPlan = new Intent(BaseCountingActivity.this, MainActivity.class);
    intent.putExtra("justStart", true);
    intent.putExtra("pid", nfc.pid);
    startActivity(intentNewPlan);
    

    MainActivity 的 launchMode 是 singleTask ,同时我有在 onNewIntent()里面去 setIntent ,结果还是获取不到传递的消息。

    其它信息:
    compileSdkVersion 33
    minSdkVersion 19
    targetSdkVersion 29

    Android 版本:
    13

    Nuttertoo1s
        1
    Nuttertoo1s  
       Apr 26, 2023
    emmmmm 名字错了吧 应该是

    intentNewPlan.putExtra("justStart", true);
    intentNewPlan .putExtra("pid", nfc.pid);
    300
        2
    300  
       Apr 26, 2023
    @Nuttertoo1s #1 真相了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6137 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 02:23 · PVG 10:23 · LAX 19:23 · JFK 22:23
    ♥ Do have faith in what you're doing.