save code
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning,HardcodedDebugMode">
|
||||
|
||||
<activity android:name="com.khronos.vulkan_samples.SampleLauncherActivity"
|
||||
<activity android:name="com.khronos.vulkan_samples.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.khronos.vulkan_samples;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Debug;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.google.androidgamesdk.GameActivity;
|
||||
|
||||
public class MainActivity extends GameActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
try {
|
||||
String native_lib_name = getResources().getString(R.string.native_lib_name);
|
||||
System.loadLibrary(native_lib_name);
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
Toast.makeText(getApplicationContext(), "Native code library failed to load.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
String[] argArray = new String[2];
|
||||
argArray[0] = "sample";
|
||||
argArray[1] = "hello_triangle";
|
||||
sendArgumentsToPlatform(argArray);
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.i("MainActivity", "onCreate: ");
|
||||
}
|
||||
private native void sendArgumentsToPlatform(String[] args);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
package com.khronos.vulkan_samples;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.androidgamesdk.GameActivity;
|
||||
import com.khronos.vulkan_samples.common.Notifications;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
|
||||
public class NativeMyActivity extends GameActivity {
|
||||
|
||||
private Context context;
|
||||
|
||||
private final Semaphore semaphore = new Semaphore(0, true);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle instance) {
|
||||
super.onCreate(instance);
|
||||
|
||||
Notifications.initNotificationChannel(this);
|
||||
|
||||
context = this;
|
||||
|
||||
String[] argArray = new String[2];
|
||||
argArray[0] = "sample";
|
||||
argArray[1] = "hello_triangle";
|
||||
sendArgumentsToPlatform(argArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
View decorView = getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Handle the application when an error is thrown and display a message
|
||||
*/
|
||||
public void fatalError(String message) {
|
||||
final NativeMyActivity activity = this;
|
||||
|
||||
ApplicationInfo applicationInfo = activity.getApplicationInfo();
|
||||
|
||||
this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Vulkan Samples");
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
semaphore.release();
|
||||
}
|
||||
});
|
||||
builder.setCancelable(false);
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
try {
|
||||
semaphore.acquire();
|
||||
}
|
||||
catch (InterruptedException e) { }
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
private native void sendArgumentsToPlatform(String[] args);
|
||||
}
|
||||
Reference in New Issue
Block a user