AI2 Component  (Version nb184)
RuntimeErrorAlert.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2009-2011 Google, All Rights reserved
3 // Copyright 2011-2012 MIT, All rights reserved
4 // Released under the Apache License, Version 2.0
5 // http://www.apache.org/licenses/LICENSE-2.0
6 
7 package com.google.appinventor.components.runtime.util;
8 
9 import android.app.Activity;
10 import android.app.AlertDialog;
11 import android.content.Context;
12 import android.content.DialogInterface;
13 import android.util.Log;
14 
21 public final class RuntimeErrorAlert {
22  public static void alert(final Object context,
23  final String message, final String title,final String buttonText) {
24  Log.i("RuntimeErrorAlert", "in alert");
25  AlertDialog alertDialog = new AlertDialog.Builder((Context) context).create();
26  alertDialog.setTitle(title);
27  alertDialog.setMessage(message);
28  alertDialog.setButton(buttonText, new DialogInterface.OnClickListener() {
29  public void onClick(DialogInterface dialog, int which) {
30  ((Activity) context).finish();
31  }});
32  if (message == null) {
33  // Avoid passing null to Log.e, which would cause a NullPointerException.
34  Log.e(RuntimeErrorAlert.class.getName(), "No error message available");
35  } else {
36  Log.e(RuntimeErrorAlert.class.getName(), message);
37  }
38  alertDialog.show();
39  }
40 }
com.google.appinventor.components.runtime.util.RuntimeErrorAlert.alert
static void alert(final Object context, final String message, final String title, final String buttonText)
Definition: RuntimeErrorAlert.java:22
com.google.appinventor.components.runtime.util.RuntimeErrorAlert
Definition: RuntimeErrorAlert.java:21