Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 返回null的Intent getStringExtra_Android_Android Intent - Fatal编程技术网

Android 返回null的Intent getStringExtra

Android 返回null的Intent getStringExtra,android,android-intent,Android,Android Intent,我知道这个问题被问了很多,但我不知道哪里出了错 因此,我通过一个活动发送了一些数据,并从另一个活动中检索数据 第一个活动 Timber.i("Photo img : %s", posterUrl); String url = AppConstants.IMAGE_BASE_URL+ AppConstants.POSTER_SIZE_ORIGINAL+ posterUrl; Intent i = new Intent(this, ImageFullActivity.cla

我知道这个问题被问了很多,但我不知道哪里出了错

因此,我通过一个活动发送了一些数据,并从另一个活动中检索数据

第一个活动

Timber.i("Photo img : %s", posterUrl);
    String url = AppConstants.IMAGE_BASE_URL+ 
    AppConstants.POSTER_SIZE_ORIGINAL+ posterUrl;
    Intent i = new Intent(this, ImageFullActivity.class);
    i.putExtra(AppConstants.IMAGE_URL, url);
    startActivity(i);
接收活动

Intent i = new Intent();
String imageUrl = i.getStringExtra(AppConstants.IMAGE_URL);    
Timber.i("GOt image url %s", imageUrl);
Picasso.with(this)
      .load(imageUrl)
      .into(image);

我查过了。我不是通过临时演员传递空值。posterUrl是一个有效字符串。

您需要使用
getIntent()
获取启动下一个活动的intent实例

 getIntent().getStringExtra
而不是创建一个新的空的

//Intent i = new Intent(); remove

Intent i = getIntent(); // or do this

您需要使用
getIntent()
获取启动下一个活动的intent实例

 getIntent().getStringExtra
而不是创建一个新的空的

//Intent i = new Intent(); remove

Intent i = getIntent(); // or do this
试试这个

//Intent i = new Intent();
String imageUrl = getIntent().getStringExtra(AppConstants.IMAGE_URL);    
Timber.i("GOt image url %s", imageUrl);
Picasso.with(this)
      .load(imageUrl)
      .into(image);

Bundle bundle = getIntent().getExtras();
String imageUrl = bundle.getString(AppConstants.IMAGE_URL);
Timber.i("GOt image url %s", imageUrl);
Picasso.with(this)
      .load(imageUrl)
      .into(image);
试试这个

//Intent i = new Intent();
String imageUrl = getIntent().getStringExtra(AppConstants.IMAGE_URL);    
Timber.i("GOt image url %s", imageUrl);
Picasso.with(this)
      .load(imageUrl)
      .into(image);

Bundle bundle = getIntent().getExtras();
String imageUrl = bundle.getString(AppConstants.IMAGE_URL);
Timber.i("GOt image url %s", imageUrl);
Picasso.with(this)
      .load(imageUrl)
      .into(image);
您需要通过getIntent()方法获取意图


您需要通过getIntent()方法获取意图

问题在于,您试图在接收活动中创建新的意图,而接收活动中没有您在其他
活动中传递的数据。
要获取在其他活动中传递的意图,请使用
getIntent()


此处,此意图将保存您从其他活动传递的数据。

问题在于,您试图在接收活动中创建新意图,而该活动中没有您在其他
活动中传递的数据。
要获取在其他活动中传递的意图,请使用
getIntent()


这里的目的是保存您从其他活动中传递的数据。

@SriramR我很高兴能为您提供帮助,happycoding@SriramR我很高兴能帮上忙,很高兴