List of usage examples for android.app PendingIntent send
public void send(int code) throws CanceledException
From source file:com.jefftharris.passwdsafe.sync.lib.AccountChooserDlg.java
/** Handle a selected account */ private void onAccountSelected(String accountName) { Bundle args = getArguments();// w w w . j a v a 2 s . c o m int requestCode = args.getInt("requestCode"); int result; Intent intent = new Intent(); if (accountName != null) { intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, accountName); result = Activity.RESULT_OK; } else { result = Activity.RESULT_CANCELED; } PendingIntent pendIntent = getActivity().createPendingResult(requestCode, intent, PendingIntent.FLAG_ONE_SHOT); try { pendIntent.send(result); } catch (PendingIntent.CanceledException e) { Log.e(TAG, "intent send failed", e); } }
From source file:com.concentricsky.android.khanacademy.data.KADataService.java
private void finish(int startId, PendingIntent pendingIntent, int result) { if (pendingIntent != null) { try {// w ww .ja v a2 s. c o m pendingIntent.send(result); } catch (CanceledException e) { // Ignore this. If they don't want their result, they don't get it. } } this.stopSelfResult(startId); }
From source file:com.jefftharris.passwdsafe.sync.onedrive.OnedriveProvider.java
/** * Start the process of linking to an account *//*w ww .j av a 2 s. c o m*/ @Override public void startAccountLink(final FragmentActivity activity, final int requestCode) { Runnable loginTask = new Runnable() { @Override public void run() { itsAuthClient.login(activity, null, new AuthListener() { @Override public void onAuthComplete(AuthStatus status, AuthSession session, Object userState) { PasswdSafeUtil.dbginfo(TAG, "login ok status %s, sess [%s]", status, session); switch (status) { case CONNECTED: { Intent intent = new Intent(); PendingIntent pendIntent = activity.createPendingResult(requestCode, intent, PendingIntent.FLAG_ONE_SHOT); try { pendIntent.send(Activity.RESULT_OK); } catch (PendingIntent.CanceledException e) { Log.e(TAG, "login intent send failed", e); } break; } case NOT_CONNECTED: case UNKNOWN: { Log.e(TAG, "Auth complete, bad status: " + status); break; } } } @Override public void onAuthError(AuthException exception, Object userState) { Log.e(TAG, "Auth error", exception); } }); } }; if (isAccountAuthorized()) { unlinkAccount(loginTask); } else { loginTask.run(); } }