Example usage for android.content Intent setClass

List of usage examples for android.content Intent setClass

Introduction

In this page you can find the example usage for android.content Intent setClass.

Prototype

public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) 

Source Link

Document

Convenience for calling #setComponent(ComponentName) with the name returned by a Class object.

Usage

From source file:at.jclehner.rxdroid.DrugListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menuitem_date: {
        if (isShowingCurrentDate())
            mDateClickListener.onLongClick(null);
        else/*from   w  w w. java  2s  .  c  o m*/
            mDateClickListener.onClick(null);

        return true;
    }
    case R.id.menuitem_patient: {

    }
    case R.id.menuitem_add: {
        Intent intent = new Intent(Intent.ACTION_INSERT);
        intent.setClass(this, DrugEditActivity.class);
        startActivity(intent);
        return true;
    }
    case R.id.menuitem_preferences: {
        Intent intent = new Intent();
        intent.setClass(this, PreferencesActivity.class);
        startActivity(intent);
        return true;
    }
    case R.id.menuitem_toggle_filtering: {
        mShowingAll = !mShowingAll;
        invalidateViewPager();
        return true;
    }
    case R.id.menuitem_take_all_pending: {
        final List<Drug> drugs = Entries.getAllDrugs(mCurrentPatientId);
        final DoseTimeInfo dtInfo = Settings.getDoseTimeInfo();
        final int activeDoseTime = dtInfo.activeDoseTime();
        final Date activeDate = dtInfo.activeDate();

        int toastResId = R.string._toast_no_due_doses;
        int toastLength = Toast.LENGTH_SHORT;

        if (activeDoseTime != Schedule.TIME_INVALID) {
            int taken = 0, skipped = 0;

            for (Drug drug : drugs) {
                if (!drug.isActive())
                    continue;

                if (!Entries.findDoseEvents(drug, activeDate, activeDoseTime).isEmpty())
                    continue;

                final Fraction dose = drug.getDose(activeDoseTime, activeDate);

                if (!dose.isZero()) {
                    final Fraction currentSupply = drug.getCurrentSupply();

                    if (!currentSupply.isZero()) {
                        final Fraction newSupply = currentSupply.minus(dose);

                        if (newSupply.isNegative()) {
                            ++skipped;
                            continue;
                        } else {
                            drug.setCurrentSupply(newSupply);
                            Database.update(drug);
                        }
                    }

                    Database.create(new DoseEvent(drug, activeDate, activeDoseTime, dose));
                    ++taken;
                }
            }

            if (skipped != 0) {
                toastResId = R.string._toast_some_due_doses_skipped;
                toastLength = Toast.LENGTH_LONG;
            } else if (taken != 0)
                toastResId = R.string._toast_all_due_doses_taken;
        }

        Toast.makeText(this, toastResId, toastLength).show();
    }

    }
    return super.onOptionsItemSelected(item);
}

From source file:heartware.com.heartware_master.FriendsFragment.java

private void startPickerActivity(Uri data, int requestCode) {
    Intent intent = new Intent();
    intent.setData(data);/*from w w  w .  ja  va  2s  .com*/
    intent.setClass(getActivity(), FB_PickerActivity.class);
    startActivityForResult(intent, requestCode);
}

From source file:com.android.calendar.alerts.AlertService.java

void processMessage(Message msg) {
    Bundle bundle = (Bundle) msg.obj;//w  ww  .  j a va 2s .  com

    // On reboot, update the notification bar with the contents of the
    // CalendarAlerts table.
    String action = bundle.getString("action");
    if (DEBUG) {
        Log.d(TAG, bundle.getLong(android.provider.CalendarContract.CalendarAlerts.ALARM_TIME) + " Action = "
                + action);
    }

    // Some OEMs had changed the provider's EVENT_REMINDER broadcast to their own event,
    // which broke our unbundled app's reminders.  So we added backup alarm scheduling to the
    // app, but we know we can turn it off if we ever receive the EVENT_REMINDER broadcast.
    boolean providerReminder = action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER);
    if (providerReminder) {
        if (sReceivedProviderReminderBroadcast == null) {
            sReceivedProviderReminderBroadcast = Utils.getSharedPreference(this, PROVIDER_REMINDER_PREF_KEY,
                    false);
        }

        if (!sReceivedProviderReminderBroadcast) {
            sReceivedProviderReminderBroadcast = true;
            Log.d(TAG, "Setting key " + PROVIDER_REMINDER_PREF_KEY + " to: true");
            Utils.setSharedPreference(this, PROVIDER_REMINDER_PREF_KEY, true);
        }
    }

    if (providerReminder || action.equals(Intent.ACTION_PROVIDER_CHANGED)
            || action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER)
            || action.equals(AlertReceiver.EVENT_REMINDER_APP_ACTION)
            || action.equals(Intent.ACTION_LOCALE_CHANGED)) {

        // b/7652098: Add a delay after the provider-changed event before refreshing
        // notifications to help issue with the unbundled app installed on HTC having
        // stale notifications.
        if (action.equals(Intent.ACTION_PROVIDER_CHANGED)) {
            try {
                Thread.sleep(5000);
            } catch (Exception e) {
                // Ignore.
            }
        }

        updateAlertNotification(this);
    } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
        // The provider usually initiates this setting up of alarms on startup,
        // but there was a bug (b/7221716) where a race condition caused this step to be
        // skipped, resulting in missed alarms.  This is a stopgap to minimize this bug
        // for devices that don't have the provider fix, by initiating this a 2nd time here.
        // However, it would still theoretically be possible to hit the race condition
        // the 2nd time and still miss alarms.
        //
        // TODO: Remove this when the provider fix is rolled out everywhere.
        Intent intent = new Intent();
        intent.setClass(this, InitAlarmsService.class);
        startService(intent);
    } else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
        doTimeChanged();
    } else if (action.equals(AlertReceiver.ACTION_DISMISS_OLD_REMINDERS)) {
        dismissOldAlerts(this);
    } else {
        Log.w(TAG, "Invalid action: " + action);
    }

    // Schedule the alarm for the next upcoming reminder, if not done by the provider.
    if (sReceivedProviderReminderBroadcast == null || !sReceivedProviderReminderBroadcast) {
        Log.d(TAG, "Scheduling next alarm with AlarmScheduler. " + "sEventReminderReceived: "
                + sReceivedProviderReminderBroadcast);
        AlarmScheduler.scheduleNextAlarm(this);
    }
}

From source file:org.linphone.LinphoneService.java

public void callState(final LinphoneCore lc, final LinphoneCall call, final State state, final String message) {
    Log.i(TAG, "new state [" + state + "]");
    if (state == LinphoneCall.State.IncomingReceived && !call.equals(mLinphoneCore.getCurrentCall())) {
        if (call.getReplacedCall() == null) {
            // no multicall support, just decline
            mLinphoneCore.terminateCall(call);
        } // otherwise it will be accepted automatically.

        return;// ww w  . j  av a 2 s . c o  m
    }
    if (state == LinphoneCall.State.IncomingReceived) {
        // wakeup linphone
        Intent lIntent = new Intent();
        lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        lIntent.putExtra("showAnswer", true);
        lIntent.putExtra("name", call.getRemoteAddress().getUserName());
        lIntent.setClass(this, CallingActivity.class);
        startActivity(lIntent);
        startRinging();
    }
    mHandler.post(new Runnable() {
        public void run() {
            if (CallingActivity.getDialer() != null)
                CallingActivity.getDialer().callState(lc, call, state, message);
        }
    });

    if (mCurrentCallState == LinphoneCall.State.IncomingReceived) {
        // previous state was ringing, so stop ringing
        stopRinging();
        // routeAudioToReceiver();
    }
    mCurrentCallState = state;
}

From source file:com.nuvolect.securesuite.main.SharedMenu.java

/**
 * Process a menu command and return a post command to be executed in the
 * calling activity//from  w  ww  .j a v  a 2 s .co  m
 * @return post command.
 */
private static POST_CMD process() {

    switch (m_item_id) {

    case R.id.menu_shared_search: {
        SearchDialog.manageSearch(m_act, new SearchDialog.SearchCallbacks() {
            @Override
            public void onContactSelected(long contact_id) {

                if (invalidContact(contact_id)) {
                    Toast.makeText(m_act, "Invalid contact", Toast.LENGTH_SHORT).show();
                    return;
                }

                LogUtil.log("SharedMenu.shared_search id selected: " + contact_id);
                Persist.setCurrentContactId(m_act, contact_id);
                if (m_post_cmd_callbacks == null) {

                    LogUtil.log("ERROR SharedMenu.shared_search callbacks null ");
                } else {

                    m_post_cmd_callbacks.postCommand(POST_CMD.START_CONTACT_DETAIL);
                }
            }
        });
        break;
    }
    case R.id.menu_add_contact: {
        m_contact_id = SqlCipher.createEmptyContact(m_act, Cryp.getCurrentGroup());
        Persist.setCurrentContactId(m_act, m_contact_id);

        // In case the user discards contact, it will be deleted
        Persist.setEmptyContactId(m_act, m_contact_id);
        return POST_CMD.START_CONTACT_EDIT;
    }
    case R.id.menu_delete_contact: {
        if (invalidContact(m_contact_id)) {
            Toast.makeText(m_act, "Select a contact to delete", Toast.LENGTH_SHORT).show();
            return POST_CMD.DONE;
        } else {
            long nextId = 0;
            if (m_cursor != null)
                nextId = SqlCipher.getNextContactId(m_cursor);

            boolean success;
            if (MyGroups.isInTrash(m_contact_id)) {

                success = 1 == SqlCipher.deleteContact(m_act, m_contact_id, true);//sync==true
                if (success)
                    Toast.makeText(m_act, "Contact deleted", Toast.LENGTH_SHORT).show();
            } else {

                success = MyGroups.trashContact(m_act, Cryp.getCurrentAccount(), m_contact_id);
                if (success)
                    Toast.makeText(m_act, "Item moved to trash", Toast.LENGTH_SHORT).show();
            }
            if (!success)
                LogUtil.log("SharedMenu.delete_contact delete failure: " + m_contact_id);

            MyContacts.setValidId(m_act, nextId);

            MyGroups.loadGroupMemory();
            return POST_CMD.REFRESH_LEFT_DEFAULT_RIGHT;
        }
    }
    case R.id.menu_edit_contact: {
        if (invalidContact(m_contact_id)) {
            Toast.makeText(m_act, "Invalid contact", Toast.LENGTH_SHORT).show();
            return POST_CMD.NIL;
        } else
            return POST_CMD.START_CONTACT_EDIT;
    }
    case R.id.menu_edit_save:
    case R.id.menu_edit_discard: {
        return POST_CMD.START_CONTACT_DETAIL;
    }
    case R.id.menu_share_contact: {
        if (invalidContact(m_contact_id)) {
            Toast.makeText(m_act, "Invalid contact", Toast.LENGTH_SHORT).show();
            return POST_CMD.NIL;
        }
        ExportVcf.emailVcf(m_act, Persist.getCurrentContactId(m_act));
        return POST_CMD.NIL;
    }
    case R.id.menu_set_profile:
        Persist.setProfileId(m_act, m_contact_id);
        Toast.makeText(m_act, "Profile set", Toast.LENGTH_SHORT).show();
        return POST_CMD.REFRESH_LEFT_DEFAULT_RIGHT;

    case R.id.menu_delete_group: {

        // Test for All other contacts group, it can't be deleted
        if (MyGroups.isBaseGroup(m_group_id)) {

            Toast.makeText(m_act, "This group cannot be removed", Toast.LENGTH_LONG).show();
        } else {
            // Delete the group but not the contacts in the group.
            // Remove memory based and DB group title and data records matching group ID.
            // Sync transaction to companion device.
            MyGroups.deleteGroup(m_act, m_group_id, true);// Sync transaction is true

            // Group is now gone, select a default group
            int g_id = MyGroups.getDefaultGroup(Cryp.getCurrentAccount());
            Cryp.setCurrentGroup(g_id);

            return POST_CMD.REFRESH_LEFT_DEFAULT_RIGHT;
        }
        break;
    }
    case R.id.menu_add_group: {
        Intent intent = new Intent(m_act, EditGroupActivity.class);
        m_act.startActivity(intent);
        break;
    }
    case R.id.menu_edit_group: {
        if (MyGroups.isPseudoGroup(m_group_id))
            Toast.makeText(m_act, "Can't edit this group directly", Toast.LENGTH_SHORT).show();
        else {
            Intent intent = new Intent(m_act, EditGroupActivity.class);
            intent.putExtra(CConst.GROUP_ID_KEY, Cryp.getCurrentGroup());
            m_act.startActivity(intent);
        }
        break;
    }
    case R.id.menu_merge_group:
        MergeGroup.mergeGroup(m_act);
        break;
    //FUTURE integrate OpenPGP https://github.com/open-keychain/openpgp-api
    case R.id.menu_email_group:
        GroupSendEmail.emailGroup(m_act);
        break;
    case R.id.menu_text_group: {
        GroupSendSms.startGroupSms(m_act);
        break;
    }
    case R.id.menu_import_vcard: {

        if (hasPermission(READ_EXTERNAL_STORAGE)) {

            // Kickoff a browser activity here.
            // When user selects file, onActivityResult called with the result.
            Intent intent = new Intent();
            intent.setClass(m_act, FileBrowserImportVcf.class);
            m_act.startActivityForResult(intent, CConst.IMPORT_VCARD_BROWSE_ACTION);
        } else
            PermissionUtil.requestReadExternalStorage(m_act, CConst.IMPORT_VCARD_REQUEST_EXTERNAL_STORAGE);
        break;
    }
    case R.id.menu_import_single_contact: {

        if (hasPermission(READ_CONTACTS)) {
            /**
             * Launch the contact picker intent.
             * Results returned in onActivityResult()
             */
            Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
            m_act.startActivityForResult(contactPickerIntent, CConst.IMPORT_SINGLE_CONTACT_PICKER);
        } else
            PermissionUtil.requestReadExternalStorage(m_act, CConst.IMPORT_SINGLE_CONTACT_REQUEST_READ);
        break;
    }
    case R.id.menu_import_account_contacts: {

        if (hasPermission(READ_CONTACTS) && hasPermission(GET_ACCOUNTS)) {

            CloudImportDialog.openDialog(m_act);

        } else {
            if (!hasPermission(READ_CONTACTS)) {

                PermissionUtil.requestReadContacts(m_act, CConst.IMPORT_ACCOUNT_CONTACTS_REQUEST_READ_CONTACTS);
                break;
            }
            if (!hasPermission(GET_ACCOUNTS)) {

                PermissionUtil.requestGetAccounts(m_act, CConst.IMPORT_ACCOUNT_CONTACTS_REQUEST_GET_ACCOUNTS);
                break;
            }
        }
        break;
    }
    case R.id.menu_export_group: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {

            ExportVcf.exportGroupVcardAsync(m_act, m_group_id);
            Toast.makeText(m_act, "Exporting...", Toast.LENGTH_LONG).show();
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_export_account: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {
            ExportVcf.exportAccountVcardAsync(m_act, Cryp.getCurrentAccount());
            Toast.makeText(m_act, "Exporting...", Toast.LENGTH_LONG).show();
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_export_all: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {
            ExportVcf.exportAllVcardAsync(m_act);
            Toast.makeText(m_act, "Exporting...", Toast.LENGTH_LONG).show();
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_cleanup: {
        CleanupFragment f = CleanupFragment.newInstance(m_act);
        f.startFragment();
        break;
    }
    case R.id.menu_backup_to_email: {
        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {
            BackupRestore.backupToEmail(m_act);
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_backup_to_storage: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE))
            BackupRestore.backupToStorage(m_act);
        else
            PermissionUtil.requestWriteExternalStorage(m_act, REQUEST_ID_BACKUP_TO_STORAGE);
        break;
    }
    case R.id.menu_backup_to_lan: {

        SqlFullSyncSource.getInstance().backupDiag(m_act);
        break;
    }
    case R.id.menu_accounts: {
        // import android.provider.Settings;
        m_act.startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS));
        break;
    }
    case R.id.menu_password_generator: {
        PasswordFragment f = PasswordFragment.newInstance(m_act);
        f.start();
        break;
    }
    case R.id.menu_empty_trash: {

        DialogUtil.emptyTrash(m_act, m_post_cmd_callbacks);
        break;
    }
    case R.id.menu_settings: {
        Intent intent = new Intent(m_act, SettingsActivity.class);
        m_act.startActivity(intent);
        break;
    }
    case R.id.menu_help: {
        String url = AppSpecific.APP_WIKI_URL;
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        m_act.startActivity(i);
        break;
    }
    case R.id.menu_developer: {

        DeveloperDialog.start(m_act);
        break;
    }
    default:
        if (DEBUG && m_item != null)
            LogUtil.log("SharedMenu.default: " + m_item.getTitle());
    }
    return POST_CMD.NIL;
}

From source file:com.miz.mizuu.fragments.ShowSeasonsFragment.java

private void identifyEpisode() {
    Intent i = new Intent();
    i.setClass(getActivity(), IdentifyTvShow.class);
    i.putExtra("rowId", shownEpisodes.get(selectedEpisodeIndex).getRowId());
    i.putExtra("files", new String[] { shownEpisodes.get(selectedEpisodeIndex).getFullFilepath() });
    i.putExtra("isShow", false);
    startActivity(i);//from   w  w w.j  av  a2s .c  o m
}

From source file:com.example.android.littleblack.CameraFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //to-do//from   ww  w .  j a  v a 2s.  co  m
    final GestureDetector mGestureDetector = new BuileGestureExt(getActivity(),
            new BuileGestureExt.OnGestureResult() {
                @Override
                public void onFilingResult(int direction) {
                    show(Integer.toString(direction));
                    switch (direction) {
                    case BuileGestureExt.GESTURE_UP:
                    case BuileGestureExt.GESTURE_DOWN:
                    case BuileGestureExt.GESTURE_RIGHT:
                        break;
                    case BuileGestureExt.GESTURE_LEFT:
                        /* Intent */
                        Intent intent = new Intent();
                        /* intent?? */
                        intent.setClass(getActivity(), PictureViewActivity.class);
                        /* ?Activity */
                        getActivity().startActivity(intent);
                        /* ?Activity */
                        getActivity().finish();
                        break;
                    default:
                        break;
                    }
                }

                @Override
                public void onDownResult() {
                    takePicture();
                }
            }).Buile();
    CameraActivity.OnTouchListener myOnTouchListener = new CameraActivity.OnTouchListener() {
        @Override
        public boolean onTouch(MotionEvent ev) {
            boolean result = mGestureDetector.onTouchEvent(ev);
            return result;
        }
    };

    ((CameraActivity) getActivity()).registerOnTouchListener(myOnTouchListener);
    return inflater.inflate(R.layout.fragment_camera2_basic, container, false);
}

From source file:com.apptentive.android.sdk.ApptentiveInternal.java

public void showAboutInternal(Context context, boolean showBrandingBand) {
    Intent intent = new Intent();
    intent.setClass(context, ApptentiveViewActivity.class);
    intent.putExtra(Constants.FragmentConfigKeys.TYPE, Constants.FragmentTypes.ABOUT);
    intent.putExtra(Constants.FragmentConfigKeys.EXTRA, showBrandingBand);
    if (!(context instanceof Activity)) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    }/*  w  w w .java2  s  .c  om*/
    context.startActivity(intent);
}

From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mApp = (ImApp) getApplication();/* w ww. ja v a2 s  . c o m*/
    mHandler = new MyHandler(this);

    mSignInHelper = new SignInHelper(this);

    Intent intent = getIntent();
    mDoSignIn = intent.getBooleanExtra("doSignIn", true);
    mDoLock = intent.getBooleanExtra("doLock", false);

    if (!mDoLock) {
        mApp.maybeInit(this);

    }

    if (ImApp.mUsingCacheword)
        connectToCacheWord();
    else {
        if (openEncryptedStores(null, false)) {
            IocVfs.init(this, "");
        } else {
            connectToCacheWord(); //first time setup
        }
    }

    // if we have an incoming contact, send it to the right place
    String scheme = intent.getScheme();
    if (TextUtils.equals(scheme, "xmpp")) {
        intent.setClass(this, AddContactActivity.class);
        startActivity(intent);
        finish();
        return;
    }
}

From source file:com.orange.oidc.tim.service.HttpOpenidConnect.java

public boolean getTokens(Context ctx, String id, boolean useTim, String login) {

    if (mOcp == null)
        return false;

    try {//from  w  w  w .j  a v a 2s. c om

        String requestObject = null;
        String authorization_endpoint = null;
        try {

            // retrieve openid config
            JSONObject json = getHttpJSON(mOcp.m_server_url + openIdConfigurationUrl);
            if (json == null) {
                Logd(TAG, "could not get openid-configuration on server : " + mOcp.m_server_url);
                return false;
            }

            // get authorization end_point
            authorization_endpoint = json.optString("authorization_endpoint");

            if (useTim) {
                // get jwks_uri of the server
                String jwks_uri = json.optString("jwks_uri");
                if (jwks_uri == null || jwks_uri.length() < 1) {
                    Logd(TAG, "could not get jwks_uri from openid-configuration on server : "
                            + mOcp.m_server_url);
                    return false;
                }

                // get jwks
                String jwks = getHttpString(jwks_uri);
                if (jwks == null || jwks.length() < 1) {
                    Logd(TAG, "could not get jwks_uri content from : " + jwks_uri);
                    return false;
                }

                // extract public key
                PublicKey serverPubKey = KryptoUtils.pubKeyFromJwk(jwks);
                if (serverPubKey == null) {
                    Logd(TAG, "could not extract public key from jwk : " + jwks);
                    return false;
                }

                // get tim request object
                requestObject = secureStorage.getTimRequestObject(mOcp.m_server_url, mOcp.m_client_id,
                        mOcp.m_scope, serverPubKey);
                Logd(TAG, "secureStorage requestObject : " + requestObject);
            }
        } catch (Exception ee) {
            // error generating request object
            ee.printStackTrace();
            return false;
        }

        // build post parameters
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
        nameValuePairs.add(new BasicNameValuePair("redirect_uri", mOcp.m_redirect_uri));
        nameValuePairs.add(new BasicNameValuePair("response_type", "code"));
        nameValuePairs.add(new BasicNameValuePair("scope", mOcp.m_scope));
        if (useTim)
            nameValuePairs.add(new BasicNameValuePair("client_id", secureStorage.getClientId()));
        else
            nameValuePairs.add(new BasicNameValuePair("client_id", mOcp.m_client_id));
        nameValuePairs.add(new BasicNameValuePair("nonce", mOcp.m_nonce));
        if (!isEmpty(requestObject)) {
            nameValuePairs.add(new BasicNameValuePair("request", requestObject));
        }
        nameValuePairs.add(new BasicNameValuePair("prompt", "consent"));

        // get URL encoded string from list of key value pairs
        String postParams = getQuery(nameValuePairs);

        // launch webview

        // init intent
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(ctx, WebViewActivity.class);

        // prepare request parameters
        intent.putExtra("id", id);

        intent.putExtra("server_url", authorization_endpoint);
        intent.putExtra("redirect_uri", mOcp.m_redirect_uri);
        intent.putExtra("client_id", mOcp.m_client_id);
        if (login != null)
            intent.putExtra("login", login);

        if (useTim) {
            intent.putExtra("use_tim", true);
        } else {
            intent.putExtra("client_secret", mOcp.m_client_secret);
        }
        intent.putExtra("postParams", postParams);

        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_NO_ANIMATION);

        // display webview
        ctx.startActivity(intent);

    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}