2017-05-01 3 views
0

특이한 문제가 있습니다.Intent.putExtra가 새로운 활동으로 데이터를 전달하지 못했지만 Bundle.putString이 매번 잘 작동합니다.

내 주요 활동에서 문자열을 의도에 넣고 활동에 전달하면 화면이 공백으로 남습니다. 그러나, 만약 내가 다시 버튼을 눌러 동일한 활동을 열면 잘로드됩니다.

gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
      @Override 
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
        Intent intent = new Intent(view.getContext(),ListingActivity.class); 
        intent.putExtra("rss-url",section.get(position).RssUrl); 
        startActivity(intent,bundle); 
      } 
    }); 

그러나, 대신 intent.putExtra, 나는이 번들로 같은 URL을 넣고 같은 활동에 그것을 전달하는 경우, 모든 작품이 예상대로 목록이 나타납니다합니다.

bundle.putString("rss-url",section.get(position).RssUrl); 
    startActivity(intent,bundle); 

이것은 크게 혼란 스럽습니다. 두 번째로로드되거나 화면이 회전 될 때 시작된 활동의 목록이 모두 정상적으로로드되는 이유는 무엇입니까?

번들을 사용하여 문제를 해결했지만 실제로 intent.putextra가 작동하지 않는 이유를 알고 싶습니다. 어떤 도움이라도 대단히 감사합니다.

감사

답변

0

intent.putExtra를 통해 엑스트라를 통과하면 다음과 같이 startActivity를()에 번들을 통과 할 필요가 없지만 :

gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
      @Override 
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
        Intent intent = new Intent(view.getContext(),ListingActivity.class); 
        intent.putExtra("rss-url",section.get(position).RssUrl); 
        startActivity(intent); 
      } 
    });