There was an error while loading. Please reload this page.
1 parent f601ab3 commit d5a41ceCopy full SHA for d5a41ce
1 file changed
core/src/processing/android/PFragment.java
@@ -159,20 +159,22 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
159
Bundle savedInstanceState) {
160
if (sketch != null) {
161
sketch.initSurface(inflater, container, savedInstanceState, this, null);
162
+
163
+ // For compatibility with older sketches that run some hardware initialization
164
+ // inside onCreate(), don't call from Fragment.onCreate() because the surface
165
+ // will not be yet ready, and so the reference to the activity and other
166
+ // system variables will be null. In any case, onCreateView() is called
167
+ // immediately after onCreate():
168
+ // https://developer.android.com/reference/android/app/Fragment.html#Lifecycle
169
+ sketch.onCreate(savedInstanceState);
170
171
return sketch.getSurface().getRootView();
172
} else {
173
return null;
174
}
175
176
177
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (sketch != null) sketch.onCreate(savedInstanceState);
- }
-
178
@Override
179
public void onStart() {
180
super.onStart();
0 commit comments