Add toast message per lifecycle event
Bug: 357827587
Test: run the terminal
Change-Id: I2dc3d1223f2b76c3e61c916f9673142cb5590148
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
index 2112f89..2c29818 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
@@ -26,6 +26,7 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;
+import android.widget.Toast;
import com.android.virtualization.vmlauncher.VmLauncherServices;
@@ -37,6 +38,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ Toast.makeText(this, R.string.vm_creation_message, Toast.LENGTH_SHORT).show();
VmLauncherServices.startVmLauncherService(this, this);
setContentView(R.layout.activity_headless);
@@ -70,11 +72,13 @@
}
public void onVmStop() {
+ Toast.makeText(this, R.string.vm_stop_message, Toast.LENGTH_SHORT).show();
Log.i(TAG, "onVmStop()");
finish();
}
public void onVmError() {
+ Toast.makeText(this, R.string.vm_error_message, Toast.LENGTH_SHORT).show();
Log.i(TAG, "onVmError()");
finish();
}
diff --git a/android/TerminalApp/res/values/strings.xml b/android/TerminalApp/res/values/strings.xml
new file mode 100644
index 0000000..eb6476d
--- /dev/null
+++ b/android/TerminalApp/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="vm_creation_message">A VM instance is being created.</string>
+ <string name="vm_stop_message">A VM instance is stopped, finish the app.</string>
+ <string name="vm_error_message">A VM instance is crashed, finish the app.</string>
+</resources>
\ No newline at end of file