Android 如何显示库中的对话框?

Android 如何显示库中的对话框?,android,dialog,alert,aar,Android,Dialog,Alert,Aar,我正在编写一个自定义库,遇到了一个问题。我需要显示一个对话框来提示用户登录一次。我似乎无法显示库中的AlertDialog。我无法添加窗口--令牌不适用于应用程序。通过扩展自定义库应用程序类,我获得了应用程序的上下文。这是库中的应用程序类: public class MyCustomApplication extends Application { private static MyCustomApplication instance; /** * Constructor. */ publ

我正在编写一个自定义库,遇到了一个问题。我需要显示一个对话框来提示用户登录一次。我似乎无法显示库中的AlertDialog。我无法添加窗口--令牌不适用于应用程序。通过扩展自定义库应用程序类,我获得了应用程序的上下文。这是库中的应用程序类:

public class MyCustomApplication extends Application {
private static MyCustomApplication instance;

/**
 * Constructor.
 */
public MyCustomApplication () {
    instance = this;
}

/**
 * Gets the application context.
 *
 * @return the application context
 */
public static Context getContext() {
    return instance;
}
public class MyApplication extends MyCustomApplication {

@Override
public void onCreate(){
    super.onCreate();
}
这是使用库的应用程序中的代码:

public class MyCustomApplication extends Application {
private static MyCustomApplication instance;

/**
 * Constructor.
 */
public MyCustomApplication () {
    instance = this;
}

/**
 * Gets the application context.
 *
 * @return the application context
 */
public static Context getContext() {
    return instance;
}
public class MyApplication extends MyCustomApplication {

@Override
public void onCreate(){
    super.onCreate();
}
这是库中尝试显示对话框的代码:

public static void displayTerminatePopup(String title, String message){
    int size = 14;

    AlertDialog.Builder aboutBuilder = new AlertDialog.Builder(MyCustomApplication.getContext());
    aboutBuilder
            .setTitle(title)
            .setMessage(message)
            .setCancelable(false);
            .setPositiveButton("Accept",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,int id) {
                            dialog.cancel();
                        }
                    });
    final AlertDialog aboutAlert = aboutBuilder.create();
    aboutAlert.show();
    TextView textView = (TextView)  aboutAlert.findViewById(android.R.id.message);
    textView.setTextSize(size);
}
“MyCustomApplication.getContext()就是我99%确定挂起的地方。我还尝试将上下文直接传递给库,但也没有成功。任何关于如何显示对话框以允许用户通过库登录的帮助都将不胜感激。我找了又找,什么也没找到

谢谢