Java Code Examples for android.app.Dialog#show()

The following examples show how to use android.app.Dialog#show() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FaceTrackerActivity.java    From android-vision with Apache License 2.0 6 votes vote down vote up
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() {

    // check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
Example 2
Source File: OcrCaptureActivity.java    From Moneycim with MIT License 6 votes vote down vote up
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() throws SecurityException {
    // Check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
Example 3
Source File: About.java    From experimental-fall-detector-android-app with MIT License 6 votes vote down vote up
private void eula(Context context) {
    // Run the guardian
    Guardian.initiate(this);
    // Load the EULA
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.eula);
    dialog.setTitle("EULA");
    WebView web = (WebView) dialog.findViewById(R.id.eula);
    web.loadUrl("file:///android_asset/eula.html");
    Button accept = (Button) dialog.findViewById(R.id.accept);
    accept.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
    dialog.show();
}
 
Example 4
Source File: NetworkHelper.java    From Bus-Tracking-Parent with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isPlayServicesAvailable(final Activity ctx) {
    GoogleApiAvailability availability = GoogleApiAvailability.getInstance();
    int isAvailable = availability.isGooglePlayServicesAvailable(ctx);
    if (isAvailable == ConnectionResult.SUCCESS) {
        return true;
    } else if (availability.isUserResolvableError(isAvailable)) {
        Dialog dialog = availability.getErrorDialog(ctx, isAvailable, 0);
        dialog.show();
    }else{
        L.err("cant find play services.");
        Toasty.error(ctx,"cant find play services").show();
    }
    return false;
}
 
Example 5
Source File: ToolUtils.java    From KUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 统一显示
 * 解决badtoken问题,一劳永逸
 *
 * @param dialog
 */
public static void showDialog(Dialog dialog) {
    try {
        dialog.show();
    } catch (Exception e) {
    }
}
 
Example 6
Source File: StytledDialog.java    From DialogUtils with Apache License 2.0 5 votes vote down vote up
private static Dialog showIosAlert(Context context, boolean isButtonVerticle, String title, String msg,
                                       String firstTxt, String secondTxt, String thirdTxt,
                                       boolean outsideCancleable, boolean cancleable,
                                       final MyDialogListener listener){

    Dialog dialog = buildDialog(context,cancleable,outsideCancleable);

   int  height =   assigIosAlertView(context,dialog,isButtonVerticle,title,msg,firstTxt,secondTxt,thirdTxt,listener);

    setDialogStyle(context,dialog,height);

    dialog.show();
    return dialog;
}
 
Example 7
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener, View view) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setView(view).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            dialog.show();
        }
    }
}
 
Example 8
Source File: UIs.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Context context, Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    if (activity != null) {
        String title = context.getString(2131100003);
        String msg = context.getString(messageId);
        String y = context.getString(yes);
        Dialog dialog = new Builder(activity).setTitle(title).setMessage(msg).setPositiveButton(y, yesListener).setNegativeButton(context.getString(no), noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 9
Source File: RequestLedianPayTask.java    From letv with Apache License 2.0 5 votes vote down vote up
private void showDialog(Dialog dlg) {
    if (dlg != null) {
        if (dlg.isShowing()) {
            dlg.cancel();
        } else {
            dlg.show();
        }
    }
}
 
Example 10
Source File: BaseGameUtils.java    From 8bitartist with Apache License 2.0 5 votes vote down vote up
/**
 * Show a {@link android.app.Dialog} with the correct message for a connection error.
 *  @param activity the Activity in which the Dialog should be displayed.
 * @param requestCode the request code from onActivityResult.
 * @param actResp the response code from onActivityResult.
 * @param errorDescription the resource id of a String for a generic error message.
 */
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
    if (activity == null) {
        Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.app_misconfigured));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.sign_in_failed));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.license_failed));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, requestCode, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("BaseGamesUtils",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
            }
    }

    errorDialog.show();
}
 
Example 11
Source File: FriendInfoActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void updateUserInfo() {
    final Dialog dialog = DialogCreator.createLoadingDialog(FriendInfoActivity.this,
            FriendInfoActivity.this.getString(R.string.jmui_loading));
    dialog.show();
    if (TextUtils.isEmpty(mTargetId) && !TextUtils.isEmpty(mUserID)) {
        mTargetId = mUserID;
    }
    JMessageClient.getUserInfo(mTargetId, mTargetAppKey, new GetUserInfoCallback() {
        @Override
        public void gotResult(int responseCode, String responseMessage, UserInfo info) {
            dialog.dismiss();
            if (responseCode == 0) {
                //拉取好友信息时候要更新数据库中的nickName.因为如果对方修改了nickName我们是无法感知的.如果不在拉取信息
                //时候更新数据库的话会影响到搜索好友的nickName, 注意要在没有备注名并且有昵称时候去更新.因为备注名优先级更高
                new Update(FriendEntry.class).set("DisplayName=?", info.getDisplayName()).where("Username=?", mTargetId).execute();
                new Update(FriendEntry.class).set("NickName=?", info.getNickname()).where("Username=?", mTargetId).execute();
                new Update(FriendEntry.class).set("NoteName=?", info.getNotename()).where("Username=?", mTargetId).execute();

                if (info.getAvatarFile() != null) {
                    new Update(FriendEntry.class).set("Avatar=?", info.getAvatarFile().getAbsolutePath()).where("Username=?", mTargetId).execute();
                }
                mUserInfo = info;
                mFriendInfoController.setFriendInfo(info);
                mTitle = info.getNotename();
                if (TextUtils.isEmpty(mTitle)) {
                    mTitle = info.getNickname();
                }
                mFriendInfoView.initInfo(info);
            } else {
                HandleResponseCode.onHandle(FriendInfoActivity.this, responseCode, false);
            }
        }
    });
}
 
Example 12
Source File: ProgressDialog.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
public static Dialog show(Context ctx, String text) {
    final Dialog dialog = new Dialog(ctx, R.style.full_screen_dialog);
    dialog.setContentView(R.layout.progress_dialog);
    ((TextView) dialog.findViewById(R.id.label_loading)).setText(text);
    dialog.setCancelable(false);
    dialog.show();
    return dialog;
}
 
Example 13
Source File: MainActivity.java    From WebviewProject with MIT License 5 votes vote down vote up
void showSplash(){
    splashScreenDialog=new Dialog(this,android.R.style.Theme_DeviceDefault_Light_NoActionBar_Fullscreen);
    splashScreenDialog.setContentView(R.layout.splash_screen);
    splashScreenDialog.show();
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            splashScreenDialog.dismiss();
        }
    }, 4000);
}
 
Example 14
Source File: BaseGameUtils.java    From FlappyCow with MIT License 5 votes vote down vote up
/**
 * Show a {@link android.app.Dialog} with the correct message for a connection error.
 *  @param activity the Activity in which the Dialog should be displayed.
 * @param requestCode the request code from onActivityResult.
 * @param actResp the response code from onActivityResult.
 * @param errorDescription the resource id of a String for a generic error message.
 */
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
    if (activity == null) {
        Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.app_misconfigured));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.sign_in_failed));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.license_failed));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, requestCode, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("BaseGamesUtils",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
            }
    }

    errorDialog.show();
}
 
Example 15
Source File: DialogPreference.java    From MaterialPreferenceLibrary with Apache License 2.0 5 votes vote down vote up
/**
     * Shows the dialog associated with this Preference. This is normally initiated
     * automatically on clicking on the preference. Call this method if you need to
     * show the dialog on some other event.
     *
     * @param state Optional instance state to restore on the dialog
     */
    protected void showDialog(Bundle state) {
        Context context = getContext();

        mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
        mBuilder = new AlertDialog.Builder(context)
                .setTitle(mDialogTitle)
                .setIcon(mDialogIcon)
                .setPositiveButton(mPositiveButtonText, this)
                .setNegativeButton(mNegativeButtonText, this);
        View contentView = onCreateDialogView();
        if (contentView != null) {
            onBindDialogView(contentView);
            mBuilder.setView(contentView);
        } else {
            mBuilder.setMessage(mDialogMessage);
        }

        onPrepareDialogBuilder(mBuilder);
        PreferenceManagerEx.getInstance().registerOnActivityDestroyListener(getPreferenceManager(), this);

// Create the dialog
        final Dialog dialog = mDialog = mBuilder.create();
        if (state != null) {
            dialog.onRestoreInstanceState(state);
        }
        if (needInputMethod()) {
            requestInputMethod(dialog);
        }
        dialog.setOnDismissListener(this);
        dialog.show();
    }
 
Example 16
Source File: CordovaActivity.java    From reader with MIT License 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
Example 17
Source File: VerificationActivity.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private void sendAddReason() {
    final String userName;
    String displayName;
    String targetAvatar;
    Long targetUid;
    if (getIntent().getFlags() == 1) {
        //添加好友申请时对方信息
        userName = getIntent().getStringExtra("detail_add_friend");
        displayName = getIntent().getStringExtra("detail_add_nick_name");
        targetAvatar = getIntent().getStringExtra("detail_add_avatar_path");
        targetUid = getIntent().getLongExtra("detail_add_uid", 0);
        if (TextUtils.isEmpty(displayName)) {
            displayName = userName;
        }
        //搜索方式添加好友
    } else {
        targetAvatar = InfoModel.getInstance().getAvatarPath();
        displayName = InfoModel.getInstance().getNickName();
        targetUid = InfoModel.getInstance().getUid();
        if (TextUtils.isEmpty(displayName)) {
            displayName = InfoModel.getInstance().getUserName();
        }
        userName = InfoModel.getInstance().getUserName();
    }
    final String reason = mEt_reason.getText().toString();
    final String finalTargetAvatar = targetAvatar;
    final String finalDisplayName = displayName;
    final Long finalUid = targetUid;
    final Dialog dialog = DialogCreator.createLoadingDialog(this, this.getString(R.string.jmui_loading));
    dialog.show();
    ContactManager.sendInvitationRequest(userName, null, reason, new BasicCallback() {
        @Override
        public void gotResult(int responseCode, String responseMessage) {
            dialog.dismiss();
            if (responseCode == 0) {
                UserEntry userEntry = UserEntry.getUser(mMyInfo.getUserName(), mMyInfo.getAppKey());
                FriendRecommendEntry entry = FriendRecommendEntry.getEntry(userEntry,
                        userName, mTargetAppKey);
                if (null == entry) {
                    entry = new FriendRecommendEntry(finalUid, userName, "", finalDisplayName, mTargetAppKey,
                            finalTargetAvatar, finalDisplayName, reason, FriendInvitation.INVITING.getValue(), userEntry, 100);
                } else {
                    entry.state = FriendInvitation.INVITING.getValue();
                    entry.reason = reason;
                }
                entry.save();
                ToastUtil.shortToast(VerificationActivity.this, "申请成功");
                finish();
            } else if (responseCode == 871317) {
                ToastUtil.shortToast(VerificationActivity.this, "不能添加自己为好友");
            } else {
                ToastUtil.shortToast(VerificationActivity.this, "申请失败");
            }
        }
    });
}
 
Example 18
Source File: ZoomableImageView.java    From sctalk with Apache License 2.0 4 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    final Dialog dialog = new Dialog(getContext() , R.style.phoneNumDialog);
    setupDialogViews(dialog);
    dialog.show();
}
 
Example 19
Source File: CordovaActivity.java    From wildfly-samples with MIT License 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
Example 20
Source File: MainActivity.java    From OpenCircle with GNU General Public License v3.0 4 votes vote down vote up
private void showDialogErrorPlayServices(int errorCode)
{
    Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(this, errorCode,
                                                                       Constants.REQUEST_PLAY_SERVICES_ERROR);
    dialog.show();
}