Skip to content

Commit d39ae3e

Browse files
committed
Added onCreate() and onActivityResult() to PFragment and PApplet
This ensures backward compatibility with sketches in older versions of the mode that rely on these event handlers to initialize specialized hardware, such as BT
1 parent 8138163 commit d39ae3e

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

core/src/processing/android/PFragment.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import android.support.v4.app.FragmentManager;
3030
import android.support.v4.app.FragmentTransaction;
3131
import android.util.DisplayMetrics;
32-
32+
import android.content.Intent;
3333
import android.content.pm.ActivityInfo;
3434
import android.content.res.Configuration;
3535
import android.graphics.Point;
@@ -166,6 +166,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
166166
}
167167

168168

169+
@Override
170+
public void onCreate(Bundle savedInstanceState) {
171+
super.onCreate(savedInstanceState);
172+
if (sketch != null) sketch.onCreate(savedInstanceState);
173+
}
174+
175+
176+
@Override
177+
public void onStart() {
178+
super.onStart();
179+
if (sketch != null) sketch.onStart();
180+
}
181+
182+
169183
@Override
170184
public void onResume() {
171185
super.onResume();
@@ -181,23 +195,22 @@ public void onPause() {
181195

182196

183197
@Override
184-
public void onDestroy() {
185-
super.onDestroy();
186-
if (sketch != null) sketch.onDestroy();
198+
public void onStop() {
199+
super.onStop();
200+
if (sketch != null) sketch.onStop();
187201
}
188202

189203

190204
@Override
191-
public void onStart() {
192-
super.onStart();
193-
if (sketch != null) sketch.onStart();
205+
public void onDestroy() {
206+
super.onDestroy();
207+
if (sketch != null) sketch.onDestroy();
194208
}
195209

196210

197211
@Override
198-
public void onStop() {
199-
super.onStop();
200-
if (sketch != null) sketch.onStop();
212+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
213+
if (sketch != null) sketch.onActivityResult(requestCode, resultCode, data);
201214
}
202215

203216

core/src/processing/core/PApplet.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,14 @@ public void onStop() {
578578
}
579579

580580

581+
public void onCreate(Bundle savedInstanceState) {
582+
}
583+
584+
585+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
586+
}
587+
588+
581589
public boolean hasPermission(String permission) {
582590
return surface.hasPermission(permission);
583591
}

0 commit comments

Comments
 (0)