我在 Activity 和 FragmentActivity 之间传递额外内容时遇到问题。
下一个代码创建 Intent 以启动新的 Activity:
Intent fichaSerie = new Intent(getActivity(),ActividadSerie.class);
NotificacionSerie serie = (NotificacionSerie) adaptador.getItem(position);
fichaSerie.putExtra("serie", serie.getID());
getActivity().startActivity(fichaSerie);
当我试图在 Fragment Activity 中获取 Extras 时,我得到一个 NullPointerException:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.serie);
String extra = getIntent().getExtras().getString("serie") //NullPointerException
}
有人知道我在代码中犯了什么错误吗?
非常感谢大家。