Reputation: 69
My application crashed when I'm trying to navigate from one activity to another.I have a menu page which consists of buttons,when i hit the first button it takes me to another activity, but when i am trying to get back to my menu activity i am getting null pointer exceptions.I don't know what is the problem exactly?
Intent intent = new Intent(VehicleNo.this,OptionMenuAct.class);
startActivity(intent);
I am using the above code to get back to menu page.I am getting problem in oncreate function.this is the code for that
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_option_menu);
t_row1=(TableRow)findViewById(R.id.t_row1);
t_row2=(TableRow)findViewById(R.id.t_row2);
t_row3=(TableRow)findViewById(R.id.t_row3);
t_row4=(TableRow)findViewById(R.id.t_row4);
t_row5=(TableRow)findViewById(R.id.t_row5);
t_row6=(TableRow)findViewById(R.id.t_row6);
t_row7=(TableRow)findViewById(R.id.t_row7);
t_row8=(TableRow)findViewById(R.id.t_row101);
t_row9=(TableRow)findViewById(R.id.t_row102);
ArrayList<String> pv = new ArrayList<String>();
pv = getIntent().getStringArrayListExtra("values");
for (String s : pv)
{
Log.d("k", s);
}
Upvotes: 0
Views: 55
Reputation: 8528
If you just want to back to menu page,you can call this.finish()
to destory current activity and back to menu page activity.
Upvotes: 0
Reputation: 1074
Your OnCreate method uses its intent and it should have an stringarraylist along with it, you are passing no such a thing. try to pass your desired stringarraylist when you are starting your menu activity
Upvotes: 1