Java 类android.view.WindowManager.BadTokenException 实例源码

项目:android-scrap    文件:DialogUtil.java   
public static void showProgressDialog(Activity activity,CharSequence title, CharSequence content){
    try{
        if(sDialog == null){
            sDialog = ProgressDialog.show(activity, title, content);
            sDialog.setCanceledOnTouchOutside(false);
            sDialog.setCancelable(false);
            sDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    sDialog = null;
                }
            });
        }else{
            if(sDialog.isShowing()){
                Log.w("showProgressDialog()", "dialog is showing...check?");
                return;
            }
        }
    }catch(BadTokenException e){
        e.printStackTrace();
    }
}
项目:OpenHAB_Room_Flipper    文件:OpenHABWidgetListActivity.java   
private void showSitemapSelectionDialog(final List<OpenHABSitemap> sitemapList) {
        Log.d(HABApplication.getLogTag(), "Opening sitemap selection dialog");
        final List<String> sitemapNameList = new ArrayList<String>();;
        for (int i=0; i<sitemapList.size(); i++) {
            sitemapNameList.add(sitemapList.get(i).getName());
        }
        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(OpenHABWidgetListActivity.this);
        dialogBuilder.setTitle("Select sitemap");
        try {
        dialogBuilder.setItems(sitemapNameList.toArray(new CharSequence[sitemapNameList.size()]),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    Log.d(HABApplication.getLogTag(), "Selected sitemap " + sitemapNameList.get(item));
                    SharedPreferences settings = 
                        PreferenceManager.getDefaultSharedPreferences(OpenHABWidgetListActivity.this);
                    Editor preferencesEditor = settings.edit();
                    preferencesEditor.putString("default_openhab_sitemap", sitemapList.get(item).getName());
                        preferencesEditor.commit();
                    openSitemap(sitemapList.get(item).getHomepageLink());
                }
            }).show();
        } catch (BadTokenException e) {
            Log.e(HABApplication.getLogTag(), "Error while showing sitemap selection dialog.", e);
//          Crittercism.logHandledException(e);
        }
    }
项目:SafeSlinger-Android    文件:BaseActivity.java   
private void showCustomContactPicker(int resultCode) {
    if (!SafeSlinger.doesUserHavePermission(Manifest.permission.READ_CONTACTS)) {
        showNote(R.string.iOS_RequestPermissionContacts);
        return;
    }
    Bundle args = new Bundle();
    args.putInt(extra.RESULT_CODE, resultCode);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_CONTACTTYPE);
            showDialog(DIALOG_CONTACTTYPE, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:SettingsActivity.java   
protected void setShowAbout() {
    mShowAbout.setSummary(SafeSlingerConfig.getVersionName());
    mShowAbout.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @SuppressWarnings("deprecation")
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (!isFinishing()) {
                try {
                    removeDialog(BaseActivity.DIALOG_ABOUT);
                    showDialog(BaseActivity.DIALOG_ABOUT);
                } catch (BadTokenException e) {
                    e.printStackTrace();
                }
            }
            return false;
        }
    });
}
项目:SafeSlinger-Android    文件:SettingsActivity.java   
protected void setShowOSL() {
    mShowOSL.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @SuppressWarnings("deprecation")
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (!isFinishing()) {
                try {
                    removeDialog(BaseActivity.DIALOG_OSL);
                    showDialog(BaseActivity.DIALOG_OSL);
                } catch (BadTokenException e) {
                    e.printStackTrace();
                }
            }
            return false;
        }
    });
}
项目:SafeSlinger-Android    文件:HomeActivity.java   
private void showIntroductionInvite(String exchName, String introName, byte[] introPhoto,
        byte[] introPush, byte[] introPubKey, long msgRowId) {
    Bundle args = new Bundle();
    args.putString(extra.EXCH_NAME, exchName);
    args.putString(extra.INTRO_NAME, introName);
    args.putByteArray(extra.PHOTO, introPhoto);
    args.putByteArray(extra.PUSH_REGISTRATION_ID, introPush);
    args.putByteArray(extra.INTRO_PUBKEY, introPubKey);
    args.putLong(extra.MESSAGE_ROW_ID, msgRowId);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_INTRO);
            showDialog(DIALOG_INTRO, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:mpdroid-2014    文件:StreamsFragment.java   
@Override
public boolean onMenuItemClick(android.view.MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
        case EDIT:
            addEdit((int) info.id, null);
            break;
        case DELETE:
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getResources().getString(R.string.deleteStream));
            builder.setMessage(String.format(getResources().getString(R.string.deleteStreamPrompt), items.get((int) info.id).getName()));

            DeleteDialogClickListener oDialogClickListener = new DeleteDialogClickListener((int) info.id);
            builder.setNegativeButton(getResources().getString(android.R.string.no), oDialogClickListener);
            builder.setPositiveButton(getResources().getString(R.string.deleteStream), oDialogClickListener);
            try {
                builder.show();
            } catch (BadTokenException e) {
                // Can't display it. Don't care.
            }
            break;
        default:
            return super.onMenuItemClick(item);
    }
    return false;
}
项目:YiBo    文件:ImageLoad4BigTask.java   
@Override
protected void onPreExecute() {
    super.onPreExecute();
    try {
        progressDialog = new ProgressDialog(context); 
        progressDialog.setMessage(context.getString(R.string.msg_big_image_loading));
        progressDialog.setCancelable(true);
        progressDialog.setOnCancelListener(onCancelListener);
        progressDialog.setOwnerActivity(context);
        progressDialog.setMax(100);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.show();
        if (isHit) {
            cancel(true);
            onPostExecute(null);
        }
    } catch (BadTokenException e) {
        if (Logger.isDebug()) {
            Log.d(LOG_TAG, e.getMessage(), e);
        }
        cancel(true);
    }

}
项目:apps-for-android    文件:AirHockey.java   
public void OnConnectionLost(String device) {
    class displayConnectionLostAlert implements Runnable {
        public void run() {
            Builder connectionLostAlert = new Builder(self);

            connectionLostAlert.setTitle("Connection lost");
            connectionLostAlert
                    .setMessage("Your connection with the other player has been lost.");

            connectionLostAlert.setPositiveButton("Ok", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            });
            connectionLostAlert.setCancelable(false);
            try {
            connectionLostAlert.show();
            } catch (BadTokenException e){
                // Something really bad happened here; 
                // seems like the Activity itself went away before
                // the runnable finished.
                // Bail out gracefully here and do nothing.
            }
        }
    }
    self.runOnUiThread(new displayConnectionLostAlert());
}
项目:apps-for-android    文件:MultiScreenVideo.java   
public void OnConnectionLost(String device) {
    class displayConnectionLostAlert implements Runnable {
        public void run() {
            Builder connectionLostAlert = new Builder(self);

            connectionLostAlert.setTitle("Connection lost");
            connectionLostAlert
                    .setMessage("Your connection with the other Android has been lost.");

            connectionLostAlert.setPositiveButton("Ok", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            });
            connectionLostAlert.setCancelable(false);
            try {
                connectionLostAlert.show();
            } catch (BadTokenException e) {
                // Something really bad happened here;
                // seems like the Activity itself went away before
                // the runnable finished.
                // Bail out gracefully here and do nothing.
            }
        }
    }
    self.runOnUiThread(new displayConnectionLostAlert());
}
项目:android-scrap    文件:DialogUtil.java   
public static void dismiss(Dialog d){
    if(d!=null && d.isShowing()){
        try{
            d.dismiss();
        }catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:talkback    文件:AutoScanController.java   
/**
 * Advances the focus to the next node in the view. If there are no more nodes that can be
 * clicked or if Auto Scan was disabled, then the scan is stopped
 */
@Override
public void run() {
    if (!SwitchAccessPreferenceActivity.isAutoScanEnabled(mContext)) {
        stopScan();
        return;
    }

    /*
     * TODO: Option selection should be configurable. This choice mimics
     * linear scanning
     */
    if (mIsScanInProgress) {
        try {
            if (mReverseScan) {
                mOptionManager.moveToParent(true);
            } else {
                mOptionManager.selectOption(OptionManager.OPTION_INDEX_NEXT);
            }
            if (mIsScanInProgress) {
                mHandler.postDelayed(mAutoScanRunnable, getAutoScanDelay());
            }
        } catch (BadTokenException exception) {
            stopScan();
            LogUtils.log(this, Log.DEBUG, "Unable to start scan: %s", exception);
        }
    }
}
项目:SevenWonders    文件:DialogUtil.java   
public static void safeShow(final Dialog dialog) {
    if ( null == dialog ) {
        return;
    }

    try {
        dialog.show();
    } catch(BadTokenException e) {
        //Do nothing. Happens on spurious calls after an activity has ended, like if a thread finishes.
    }
}
项目:SevenWonders    文件:DialogUtil.java   
public static void safeShow(final Activity activity, final int dialogId) {
    if ( null == activity ) {
        return;
    }

    try {
        activity.showDialog(dialogId);
    } catch(BadTokenException e) {
        //Do nothing. Happens on spurious calls after an activity has ended, like if a thread finishes.
    }
}
项目:SafeSlinger-Android    文件:MainActivity.java   
protected void showMessage(String title, String msg) {
    Bundle args = new Bundle();
    args.putString(EXTRA_TITLE, title);
    args.putString(EXTRA_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(MENU_MSG);
            showDialog(MENU_MSG, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:FileSaveActivity.java   
private void showFileLoader() {
    MyLog.d(TAG, mPath.getAbsolutePath());
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_LOAD_FILE);
            showDialog(DIALOG_LOAD_FILE);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:FileSaveActivity.java   
protected void showFileSaveAs() {
    Intent intent = getIntent();
    Bundle args = intent.getExtras();
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_TEXT_ENTRY);
            showDialog(DIALOG_TEXT_ENTRY, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:FilePickerActivity.java   
private void showFilePicker() {
    MyLog.d(TAG, mPath.getAbsolutePath());
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_LOAD_FILE);
            showDialog(DIALOG_LOAD_FILE);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:BaseActivity.java   
protected void showHelp(String title, String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_TITLE, title);
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_HELP);
            showDialog(DIALOG_HELP, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:BaseActivity.java   
protected void showAbout() {
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_ABOUT);
            showDialog(DIALOG_ABOUT);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:BaseActivity.java   
protected void showBackupQuery() {
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_BACKUPQUERY);
            showDialog(DIALOG_BACKUPQUERY);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:BaseActivity.java   
protected void showReference() {
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_REFERENCE);
            showDialog(DIALOG_REFERENCE);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:BaseActivity.java   
protected void showAddContactInvite() {
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_CONTACTINVITE);
            showDialog(DIALOG_CONTACTINVITE);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:SaveActivity.java   
private void showQuestion(String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_QUESTION);
            showDialog(DIALOG_QUESTION, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:SaveActivity.java   
private void showProgress(String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_PROGRESS);
            showDialog(DIALOG_PROGRESS, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:PickRecipientsActivity.java   
@SuppressWarnings("deprecation")
private void showQuestion(String msg, int position) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_MSG, msg);
    args.putInt(extra.POSITION, position);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_QUESTION);
            showDialog(DIALOG_QUESTION, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:HomeActivity.java   
private void showErrorExit(String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_ERREXIT);
            showDialog(DIALOG_ERREXIT, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:HomeActivity.java   
private void showManagePassphrases(ArrayList<UserData> recentKeys) {
    StringBuilder msg = new StringBuilder();
    long myKeyDate = SafeSlingerPrefs.getKeyDate();
    msg.append(String.format(getString(R.string.label_WarnManagePassOnlyRecentDeleted),
            new Date(myKeyDate).toLocaleString()));
    msg.append(" ");
    msg.append(getString(R.string.label_WarnManagePassFollowsAreRecent));
    msg.append("\n");
    if (recentKeys.size() == 0) {
        msg.append("  ");
        msg.append(getString(R.string.label_WarnManagePassNoMoreRecent));
    } else {
        for (UserData key : recentKeys) {
            msg.append("  ");
            msg.append(key.getUserName());
            msg.append(": ");
            msg.append(new Date(key.getKeyDate()).toLocaleString());
            msg.append("\n");
        }
    }

    Bundle args = new Bundle();
    args.putString(extra.RESID_MSG, msg.toString());
    args.putBoolean(extra.ALLOW_DELETE, (recentKeys.size() != 0));
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_MANAGE_PASS);
            showDialog(DIALOG_MANAGE_PASS, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:HomeActivity.java   
protected void showChangeSenderOptions() {
    UseContactItem profile = getContactProfile();

    String name = SafeSlingerPrefs.getContactName();
    ArrayList<UseContactItem> contacts = getUseContactItemsByName(name);

    boolean isContactInUse = !TextUtils.isEmpty(SafeSlingerPrefs.getContactLookupKey());

    Bundle args = new Bundle();
    args.putBoolean(extra.CREATED, isContactInUse);
    if (profile != null) {
        args.putString(extra.NAME, profile.text);
        args.putByteArray(extra.PHOTO, profile.icon);
        args.putString(extra.CONTACT_LOOKUP_KEY, profile.contactLookupKey);
    }
    if (contacts != null) {
        for (int i = 0; i < contacts.size(); i++) {
            UseContactItem c = contacts.get(i);
            args.putString(extra.NAME + i, c.text);
            args.putByteArray(extra.PHOTO + i, c.icon);
            args.putString(extra.CONTACT_LOOKUP_KEY + i, c.contactLookupKey);
        }
    }
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_USEROPTIONS);
            showDialog(DIALOG_USEROPTIONS, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:HomeActivity.java   
private void showProgress(String msg) {
    Bundle args = new Bundle();
    args.putInt(extra.PCT, 0);
    args.putInt(extra.MAX, 0);
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_PROGRESS);
            showDialog(DIALOG_PROGRESS, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:HomeActivity.java   
private void showProgress(String msg, int maxValue, int newValue) {
    Bundle args = new Bundle();
    args.putInt(extra.PCT, newValue);
    args.putInt(extra.MAX, maxValue);
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_PROGRESS);
            showDialog(DIALOG_PROGRESS, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:HomeActivity.java   
private void showQuestion(String msg, final int requestCode) {
    Bundle args = new Bundle();
    args.putInt(extra.REQUEST_CODE, requestCode);
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_QUESTION);
            showDialog(DIALOG_QUESTION, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:PassPhraseActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case MENU_HELP:
            showHelp(getString(R.string.title_passphrase), getString(R.string.help_passphrase));
            return true;
        case MENU_FEEDBACK:
            SafeSlinger.getApplication().showFeedbackEmail(PassPhraseActivity.this);
            return true;
        case MENU_EULA:
            showWebPage(SafeSlingerConfig.EULA_URL);
            return true;
        case MENU_PRIVACY:
            showWebPage(SafeSlingerConfig.PRIVACY_URL);
            return true;
        case MENU_ABOUT:
            if (!isFinishing()) {
                try {
                    removeDialog(BaseActivity.DIALOG_ABOUT);
                    showDialog(BaseActivity.DIALOG_ABOUT);
                } catch (BadTokenException e) {
                    e.printStackTrace();
                }
            }
            return true;
        default:
            break;
    }
    return false;
}
项目:SafeSlinger-Android    文件:PassPhraseActivity.java   
protected void showForgot() {
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_FORGOT);
            showDialog(DIALOG_FORGOT);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:SafeSlinger-Android    文件:PassPhraseActivity.java   
protected void showHelp(String title, String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_TITLE, title);
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_HELP);
            showDialog(DIALOG_HELP, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:mpd-control    文件:MainApplication.java   
private void connectMPD() 
{
    dismissAlertDialog();

    if (currentActivity != null) 
    {
           ad = new ProgressDialog(currentActivity);
           ad.setTitle(getResources().getString(R.string.app_connecting));
           ad.setMessage(getResources().getString(R.string.app_connecting_to_server));
           ad.setCancelable(false);
           ad.setOnKeyListener(new OnKeyListener() 
           {
               public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) 
               {
                   return true;
               }
           });

           try 
           {
               ad.show();
           }
           catch (BadTokenException e)
           {
           }
       }

    cancelDisconnectSheduler();

    oMPDAsyncHelper.connect();
}
项目:exchange-android    文件:BaseActivity.java   
protected void showHelp(String title, String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_TITLE, title);
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_HELP);
            showDialog(DIALOG_HELP, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:exchange-android    文件:ExchangeActivity.java   
private void showError(String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_ERROR);
            showDialog(DIALOG_ERROR, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:exchange-android    文件:ExchangeActivity.java   
private void showGroupSizePicker() {
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_GRP_SIZE);
            showDialog(DIALOG_GRP_SIZE);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}
项目:exchange-android    文件:ExchangeActivity.java   
private void showQuestion(String msg, final int requestCode) {
    Bundle args = new Bundle();
    args.putInt(extra.REQUEST_CODE, requestCode);
    args.putString(extra.RESID_MSG, msg);
    if (!isFinishing()) {
        try {
            removeDialog(DIALOG_QUESTION);
            showDialog(DIALOG_QUESTION, args);
        } catch (BadTokenException e) {
            e.printStackTrace();
        }
    }
}