Skip to content

Commit d45629a

Browse files
committed
Android add support for setting property using intent
use intent -e key value to set property value
1 parent a4b5f1c commit d45629a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

graphics-by-opengl-android/src/main/java/com/nucleus/android/NucleusActivity.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.io.InputStreamReader;
66

7+
import android.content.Intent;
78
import com.nucleus.CoreApp;
89
import com.nucleus.J2SEWindow.Configuration;
910
import com.nucleus.J2SEWindow.VideoMode;
@@ -109,13 +110,34 @@ public abstract class NucleusActivity extends Activity
109110
public void onCreate(Bundle savedInstanceState) {
110111
SimpleLogger.setLogger(new AndroidLogger());
111112
SimpleLogger.d(getClass(), "onCreate()");
113+
fetchIntentExtra();
112114
BaseImageFactory.setFactory(new AndroidImageFactory());
113115
activity = this;
114116
checkProperties();
115117
setup(getRenderVersion(), GLSurfaceView.RENDERMODE_CONTINUOUSLY);
116118
super.onCreate(savedInstanceState);
117119
}
118120

121+
private void fetchIntentExtra() {
122+
Intent intent = getIntent();
123+
if (intent != null) {
124+
Bundle bundle = intent.getExtras();
125+
if (bundle != null) {
126+
fetchProperties(bundle);
127+
}
128+
}
129+
}
130+
131+
private void fetchProperties(Bundle bundle) {
132+
for (Environment.Property p : Environment.Property.values()) {
133+
String value = bundle.getString(p.key);
134+
if (value != null) {
135+
SimpleLogger.d(getClass(), "Setting property " + p + " to " + value);
136+
System.setProperty(p.key, value);
137+
}
138+
}
139+
}
140+
119141
@Override
120142
public void onResume() {
121143
SimpleLogger.d(getClass(), "onResume()");
@@ -324,7 +346,7 @@ public void run() {
324346
* MUST be called from the UI thread!
325347
*
326348
* @param title
327-
* @param messag
349+
* @param message
328350
*/
329351
protected void showAlert(final String title, final String message) {
330352
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);

0 commit comments

Comments
 (0)