V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
nnegier
V2EX  ›  Android

Android Activity Intent 被清空?

  •  
  •   nnegier · 2023-04-26 15:11:43 +08:00 · 3154 次点击
    这是一个创建于 367 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我原有代码有一处显示启动 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  
       2023-04-26 15:27:38 +08:00
    emmmmm 名字错了吧 应该是

    intentNewPlan.putExtra("justStart", true);
    intentNewPlan .putExtra("pid", nfc.pid);
    winterbells
        2
    winterbells  
       2023-04-26 15:40:24 +08:00
    @Nuttertoo1s #1 真相了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2921 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:32 · PVG 20:32 · LAX 05:32 · JFK 08:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.