Android 在第二个活动中未收到意图

Android 在第二个活动中未收到意图,android,android-intent,Android,Android Intent,我有一个用于RecyclerView的ListAdapter,它使用onClick方法获取用户单击的任何项目的位置,然后将该值传递给ItemEditActivity: 然后,我在ItemEditActivity中收到了包含以下代码的意图: Intent Intent = getIntent(); String intValue = Intent.getStringExtra("ItemNumber"); 在传递stringo变量并确认其值正确之前,我会记录该变量

我有一个用于
RecyclerView
的ListAdapter,它使用onClick方法获取用户单击的任何项目的位置,然后将该值传递给ItemEditActivity:

然后,我在ItemEditActivity中收到了包含以下代码的意图:

Intent Intent = getIntent();
                String intValue = Intent.getStringExtra("ItemNumber");

在传递stringo变量并确认其值正确之前,我会记录该变量,但在第二个活动中尝试记录intValue时,该值为空。我做错了什么?

您正在创建一个意图,但没有使用它

// Your first Intent
Intent intent = new Intent(context, ItemEditActivity.class);
intent.putExtra("ItemNumber", stringo);

// Here, you are creating another Intent
context.startActivity(new Intent(v.getContext(), ItemEditActivity.class));
您只需通过第一个意图:

Intent intent = new Intent(context, ItemEditActivity.class);
intent.putExtra("ItemNumber", stringo);
context.startActivity(intent);
在第一次活动中

Intent intent = new Intent(MainActivity.this,ClientList.class);
intent.putExtra("ItemNumber", stringo);
startActivity(intent);
在第二视图中,您可以尝试以下方法

Bundle bundle = getIntent().getExtras(); //get the intent and data  passed
//next check that bundle is not null
if (bundle != null) {
    String intValue = bundle.getString("stringo"); 
    //try loging out the value
    Log.i("value", intValue);
}

这就是我使用意图传递数据的方式。

context.startActivity(意图)您发送了错误的意图。
Bundle bundle = getIntent().getExtras(); //get the intent and data  passed
//next check that bundle is not null
if (bundle != null) {
    String intValue = bundle.getString("stringo"); 
    //try loging out the value
    Log.i("value", intValue);
}