I have two activities MainActivity and SecondActivity
Code in activity MainActivity .java
public class MainActivity extends FragmentActivity implements OnMarkerClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main_screen);
databaseobj = new AppDatabase(MainActivity.this, null);
listview = (ListView) findViewById(R.id.store_listview);
noSavedMsg = (TextView) findViewById(R.id.no_msg);
..
..
..//Other code logic
..
}
@Override
protected void onResume() {
if (databaseobj.GetAll() != -1) { //NULL POINTER EXCEPTION
listview.setVisibility(View.GONE); //NULL POINTER EXCEPTION
noSavedMsg.setVisibility(View.VISIBLE); //NULL POINTER EXCEPTION
}
super.onResume();
}
}
I am getting the null pointer exception after returning from another activity;
MainActivity -> new intent to SecondActivity
SecondActivity->finish() then MainActivity-> onResume() NULL POINTER EXCEPTION
Please help!
NoSavedMsg? - Shayan Pourvatansuper.onResume()is first and not last in the overridden method. - laalto