-2
當應用程序關閉時,我從MainActivity onClick of Notification的onCreate()調用了fragment方法。但它給的NullPointerException()說,從父活動調用Fragment方法會導致NullPointerException?
Attempt to invoke virtual method 'OneFragment.refreshMaterial(int, int, int, int)' on a null object reference '
我打電話從MainActivity如下片段的方法,
OneFragment fragment = (OneFragment)getSupportFragmentManager().findFragmentById(R.id.container_body);
fragment.refreshMaterial();
顯然,'fragment'爲空。 – zed