gpt4 book ai didi

java.lang.NullPointerException long baba1

转载 作者:行者123 更新时间:2023-12-01 14:32:16 25 4
gpt4 key购买 nike

我正在将 long 值和 String 值作为附加值从列表 Activity 发送到 agenmin Activity 。但是在 第120行

    long baba1 = intent1.getExtras().getLong("baba",0); //line number 120

从列表 Activity 发送

          // long id from from listview

Intent i = new Intent(list.this, agenmin.class);
i.putExtra("baba", id);
startActivity(i);

//int position from listview
String c= Integer.toString(position);
Intent i1 = new Intent(list.this, agenmin.class);
i1.putExtra("abc", c);
startActivity(i1);

在接收方agenmin

            Intent i1 = getIntent();
String easyPuzzle;
easyPuzzle=i1.getStringExtra("abc");
textView2.setText(easyPuzzle);

Toast.makeText(getApplicationContext(), "Position " + (mess)+" ROWID " +(easyPuzzle), Toast.LENGTH_LONG).show();


Intent intent1 = getIntent();
long baba1 = intent1.getExtras().getLong("baba",0);
String strLong1 = Long.toString(baba1);
textView3.setText(strLong1);

Logcat:

      05-27 20:43:45.169: E/AndroidRuntime(593): FATAL EXCEPTION: main
05-27 20:43:45.169: E/AndroidRuntime(593): java.lang.NullPointerException
05-27 20:43:45.169: E/AndroidRuntime(593): at com.indianic.demo.calendark.agenmin$1.onClick(agenmin.java:120)

我启动了 agenmin Activity 两次,这就是 第 120 行处出现“java.lang.NullPointerException”的原因

最佳答案

试试这个:

PendingIntentintent1 = PendingIntent.getActivity(上下文,0, Intent ,
PendingIntent.FLAG_UPDATE_CURRENT);

关于java.lang.NullPointerException long baba1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16776298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com