我有一项活动开始其他活动:
Intent intent = new Intent(getApplicationContext(), MyActivity.class);
intent.putExtra("Data", data);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
这是MyActivity:
private GridViewPager pager;
private DotsPageIndicator dotsPageIndicator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teste);
pager = (GridViewPager) findViewById(R.id.pager);
pager.setAdapter(new GridPagerAdapter(getFragmentManager()));
dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
dotsPageIndicator.setDotFadeWhenIdle(false);
dotsPageIndicator.setPager(pager);
}
@Override
public void onResume(){
super.onResume();
runOnUiThread(new Runnable() {
public void run() {
pager.getAdapter().notifyDataSetChanged();
}
});
}
这是寻呼机中包含的一个片段。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.activity_lista_atividades, container, false);
if(getActivity().getIntent().getByteArrayExtra("Data")!=null) {
Log.w("AAAAaA","HJKH");
}
return view;
}
我想知道为什么这一行:
getActivity().getIntent().getByteArrayExtra("Data")
返回null。