Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

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

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:com.abplus.surroundcalc.billing.BillingHelper.java

int getResponseCodeFromIntent(Intent i) {
    return getResponseCodeFromBundle(i.getExtras());
}

From source file:com.notifry.android.UpdaterService.java

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);

    // Null intent? Weird, but deal with it.
    if (intent == null) {
        return;/*from   w  ww  .ja va  2  s  . c  om*/
    }

    // Fetch a wakelock if we don't already have one.
    // TODO: This is disabled until I can figure out the "under locked"
    // exception.
    /*
     * if( this.wakelock == null ) { PowerManager manager = (PowerManager)
     * getSystemService(Context.POWER_SERVICE); this.wakelock =
     * manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
     * this.wakelock.acquire(60000); // Max 60 seconds. }
     */

    // We need to make some kind of backend request.
    String type = intent.getExtras().getString("type");

    if (type.equals("registration")) {
        // We want to update our registration key with the server.
        // Get a list of accounts. We need to send it to any enabled ones on
        // the backend.
        ArrayList<NotifryAccount> accounts = NotifryAccount.FACTORY.listAll(this);

        String newRegistration = intent.getExtras().getString("registration");

        // TODO: Notify the user if this fails.
        for (NotifryAccount account : accounts) {
            if (account.getEnabled().booleanValue()) {
                HashMap<String, Object> metadata = new HashMap<String, Object>();
                metadata.put("account", account);
                metadata.put("operation", "register");
                metadata.put("registration", newRegistration);
                account.registerWithBackend(this, newRegistration, true, null, handler, metadata);
            }
        }
    } else if (type.equals("sourcechange")) {
        // Somewhere, a source has changed or been added. We should pull
        // down a local one.
        Long serverSourceId = Long.valueOf(intent.getLongExtra("sourceId", 0));
        Long serverDeviceId = Long.valueOf(intent.getLongExtra("deviceId", 0));

        BackendRequest request = new BackendRequest("/sources/get");
        request.add("id", serverSourceId.toString());
        request.addMeta("operation", "updatedSource");
        request.addMeta("context", this);
        request.addMeta("source_id", serverSourceId);
        request.addMeta("account_id", serverDeviceId);

        // Where to come back when we're done.
        request.setHandler(handler);

        NotifryAccount account = NotifryAccount.FACTORY.getByServerId(this, serverDeviceId);

        // Start a thread to make the request.
        // But if there was no account to match that device, don't bother.
        if (account != null) {
            request.startInThread(this, null, account.getAccountName());
        }
    }
}

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java

@Override
public void create() {
    try {// w w w .ja  v a  2s.c  o m
        setContentView(R.layout.grouped_contacts_details);

        Intent currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");
        if (widget == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }

        person = (Person) store.getSerializable("person");
        if (person == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }
        setTopBarTitle(widget.getTitle());

        Boolean single = currentIntent.getBooleanExtra("single", true);

        setTopBarLeftButtonTextAndColor(
                single ? getResources().getString(R.string.common_home_upper)
                        : getResources().getString(R.string.common_back_upper),
                getResources().getColor(android.R.color.black), true, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                    }
                });
        setTopBarTitleColor(getResources().getColor(android.R.color.black));
        setTopBarBackgroundColor(Statics.color1);

        if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) {

            ImageView shareButton = (ImageView) getLayoutInflater()
                    .inflate(R.layout.grouped_contacts_share_button, null);
            shareButton.setLayoutParams(
                    new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density),
                            (int) (39 * getResources().getDisplayMetrics().density)));
            shareButton.setColorFilter(Color.BLACK);
            setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share),
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder();

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                                sharingDialogBuilder
                                        .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();
                                                Intent email = new Intent(Intent.ACTION_SEND);
                                                email.putExtra(Intent.EXTRA_TEXT, message);
                                                email.setType("message/rfc822");
                                                startActivity(Intent.createChooser(email,
                                                        getString(R.string.choose_email_client)));
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                                sharingDialogBuilder
                                        .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();

                                                try {
                                                    Utils.sendSms(ContactDetailsActivity.this, message);
                                                } catch (ActivityNotFoundException e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT)))
                                sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook,
                                        R.drawable.gc_add_to_contacts, true,
                                        new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                createNewContact(person.getName(), person.getPhone(),
                                                        person.getEmail());
                                            }
                                        });

                            showDialogSharing(sharingDialogBuilder.build());
                        }
                    });

        }

        boolean hasSchema = store.getBoolean("hasschema");
        cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder();

        contacts = person.getContacts();

        if (widget.getTitle().length() > 0) {
            setTitle(widget.getTitle());
        }

        root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root);

        if (hasSchema) {
            root.setBackgroundColor(Statics.color1);
        } else if (widget.isBackgroundURL()) {
            cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL());
            File backgroundFile = new File(cacheBackgroundFile);
            if (backgroundFile.exists()) {
                root.setBackgroundDrawable(
                        new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile))));
            } else {
                BackgroundDownloadTask dt = new BackgroundDownloadTask();
                dt.execute(widget.getBackgroundURL());
            }
        } else if (widget.isBackgroundInAssets()) {
            AssetManager am = this.getAssets();
            root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL())));
        }

        if (contacts != null) {
            ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar);

            avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            if (person.hasAvatar() && NetworkUtils.isOnline(this)) {
                avatarImage.setVisibility(View.VISIBLE);
                Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar)
                        .dontAnimate().into(avatarImage);
            } else {
                avatarImage.setVisibility(View.VISIBLE);
                avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            }

            String name = "";
            neededContacts = new ArrayList<>();
            for (Contact con : contacts) {
                if ((con.getType() == 5) || (con.getDescription().length() == 0)) {
                } else {
                    if (con.getType() == 0) {
                        name = con.getDescription();
                    } else
                        neededContacts.add(con);
                }
            }

            if (neededContacts.isEmpty()) {
                handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA);
                return;
            }

            headSeparator = findViewById(R.id.gc_head_separator);
            bottomSeparator = findViewById(R.id.gc_bottom_separator);
            imageBottom = findViewById(R.id.gc_image_bottom_layout);
            personName = (TextView) findViewById(R.id.gc_details_description);

            if ("".equals(name))
                personName.setVisibility(View.GONE);
            else {
                personName.setVisibility(View.VISIBLE);
                personName.setText(name);
                personName.setTextColor(Statics.color3);
            }
            if (Statics.isLight) {
                headSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
            } else {
                headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
            }

            ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1);

            ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view);
            list.setDivider(null);

            ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this,
                    R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1));
            list.setAdapter(adapter);
            list.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
                    listViewItemClick(position);
                }
            });
        }

        if (widget.hasParameter("add_contact")) {
            HashMap<String, String> hm = new HashMap<>();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    hm.put("contactName", contacts.get(i).getDescription());
                }
                    break;
                case 1: {
                    hm.put("contactNumber", contacts.get(i).getDescription());
                }
                    break;
                case 2: {
                    hm.put("contactEmail", contacts.get(i).getDescription());
                }
                    break;
                case 3: {
                    hm.put("contactSite", contacts.get(i).getDescription());
                }
                    break;
                }
            }
            addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm);
        }
        if (widget.hasParameter("send_sms")) {
            HashMap<String, String> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                sb.append(contacts.get(i).getDescription());
                if (i < contacts.size() - 1) {
                    sb.append(", ");
                }
            }
            hm.put("text", sb.toString());
            addNativeFeature(NATIVE_FEATURES.SMS, null, hm);
        }
        if (widget.hasParameter("send_mail")) {
            HashMap<String, CharSequence> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    sb.append("Name: ");
                }
                    break;
                case 1: {
                    sb.append("Phone: ");
                }
                    break;
                case 2: {
                    sb.append("Email: ");
                }
                    break;
                case 3: {
                    sb.append("Site: ");
                }
                    break;
                case 4: {
                    sb.append("Address: ");
                }
                    break;
                }
                sb.append(contacts.get(i).getDescription());
                sb.append("<br/>");
            }

            if (widget.isHaveAdvertisement()) {
                sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)");
            }

            hm.put("text", sb.toString());
            hm.put("subject", "Contacts");
            addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm);
        }

    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.svpino.longhorn.MarketCollectorService.java

@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences sharedPreferences = getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE);
    long lastUpdate = sharedPreferences.getLong(Constants.PREFERENCE_COLLECTOR_LAST_UPDATE, 0);
    boolean retrying = sharedPreferences.getBoolean(Constants.PREFERENCE_COLLECTOR_RETRYING, false);
    int retries = sharedPreferences.getInt(Constants.PREFERENCE_COLLECTOR_RETRIES, 0);
    boolean wereWeWaitingForConnectivity = sharedPreferences
            .getBoolean(Constants.PREFERENCE_STATUS_WAITING_FOR_CONNECTIVITY, false);

    boolean isGlobalCollection = intent.getExtras() == null
            || (intent.getExtras() != null && !intent.getExtras().containsKey(EXTRA_TICKER));

    if (wereWeWaitingForConnectivity) {
        Editor editor = sharedPreferences.edit();
        editor.putBoolean(Constants.PREFERENCE_STATUS_WAITING_FOR_CONNECTIVITY, false);
        editor.commit();/*from  w  w w .  j a  v  a2s  .co  m*/
    }

    if (retrying && isGlobalCollection) {
        Editor editor = sharedPreferences.edit();
        editor.putBoolean(Constants.PREFERENCE_COLLECTOR_RETRYING, false);
        editor.putInt(Constants.PREFERENCE_COLLECTOR_RETRIES, 0);
        editor.commit();

        ((AlarmManager) getSystemService(Context.ALARM_SERVICE))
                .cancel(Extensions.createPendingIntent(this, Constants.SCHEDULE_RETRY));
    }

    long currentTime = System.currentTimeMillis();
    if (retrying || wereWeWaitingForConnectivity || !isGlobalCollection
            || (isGlobalCollection && currentTime - lastUpdate > Constants.COLLECTOR_MIN_REFRESH_INTERVAL)) {
        String[] tickers = null;

        if (isGlobalCollection) {
            Log.d(LOG_TAG, "Executing global market information collection...");
            tickers = DataProvider.getStockDataTickers(this);
        } else {
            String ticker = intent.getExtras().containsKey(EXTRA_TICKER)
                    ? intent.getExtras().getString(EXTRA_TICKER)
                    : null;

            Log.d(LOG_TAG, "Executing market information collection for ticker " + ticker + ".");

            tickers = new String[] { ticker };
        }

        try {
            collect(tickers);

            if (isGlobalCollection) {
                Editor editor = sharedPreferences.edit();
                editor.putLong(Constants.PREFERENCE_COLLECTOR_LAST_UPDATE, System.currentTimeMillis());
                editor.commit();
            }

            DataProvider.notifyDataCollectionIsFinished(this, tickers);

            Log.d(LOG_TAG, "Market information collection was successfully completed");
        } catch (Exception e) {
            Log.e(LOG_TAG, "Market information collection failed.", e);

            if (Extensions.areWeOnline(this)) {
                Log.d(LOG_TAG, "Scheduling an alarm for retrying a global market information collection...");

                retries++;

                Editor editor = sharedPreferences.edit();
                editor.putBoolean(Constants.PREFERENCE_COLLECTOR_RETRYING, true);
                editor.putInt(Constants.PREFERENCE_COLLECTOR_RETRIES, retries);
                editor.commit();

                long interval = Constants.COLLECTOR_MIN_RETRY_INTERVAL * retries;
                if (interval > Constants.COLLECTOR_MAX_REFRESH_INTERVAL) {
                    interval = Constants.COLLECTOR_MAX_REFRESH_INTERVAL;
                }

                ((AlarmManager) getSystemService(Context.ALARM_SERVICE)).set(AlarmManager.RTC,
                        System.currentTimeMillis() + interval,
                        Extensions.createPendingIntent(this, Constants.SCHEDULE_RETRY));
            } else {
                Log.d(LOG_TAG,
                        "It appears that we are not online, so let's start listening for connectivity updates.");

                Editor editor = sharedPreferences.edit();
                editor.putBoolean(Constants.PREFERENCE_STATUS_WAITING_FOR_CONNECTIVITY, true);
                editor.commit();

                ComponentName componentName = new ComponentName(this, ConnectivityBroadcastReceiver.class);
                getPackageManager().setComponentEnabledSetting(componentName,
                        PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
            }
        }
    } else if (isGlobalCollection && currentTime - lastUpdate <= Constants.COLLECTOR_MIN_REFRESH_INTERVAL) {
        Log.d(LOG_TAG, "Global market information collection will be skipped since it was performed less than "
                + (Constants.COLLECTOR_MIN_REFRESH_INTERVAL / 60 / 1000) + " minutes ago.");
    }

    stopSelf();
}

From source file:com.novachevskyi.expenseslite.presentation.utils.purchases.utils.IabHelper.java

int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras().get(RESPONSE_CODE);
    if (o == null) {
        logError("Intent with no response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer) {
        return ((Integer) o).intValue();
    } else if (o instanceof Long) {
        return (int) ((Long) o).longValue();
    } else {/* w ww.ja v a2s. c o m*/
        logError("Unexpected type for intent response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}

From source file:com.dileepindia.cordova.sms.SMSPlugin.java

protected void createIncomingSMSReceiver() {
    Context ctx = this.cordova.getActivity();

    this.mReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            Log.d("SMSPlugin", "onRecieve: " + action);

            if ("android.provider.Telephony.SMS_RECEIVED".equals(action)) {
                if (SMSPlugin.this.mIntercept) {
                    abortBroadcast();//from   ww w.  j av  a  2s .c  o m
                }
                Bundle bundle = intent.getExtras();
                if (bundle != null) {
                    Object[] pdus = (Object[]) bundle.get("pdus");
                    if (pdus.length != 0) {
                        for (int i = 0; i < pdus.length; i++) {
                            SmsMessage sms = SmsMessage.createFromPdu((byte[]) pdus[i]);

                            JSONObject json = SMSPlugin.this.getJsonFromSmsMessage(sms);
                            SMSPlugin.this.onSMSArrive(json);
                        }

                    }
                }
            }
        }
    };
    String[] filterstr = { "android.provider.Telephony.SMS_RECEIVED" };
    for (int i = 0; i < filterstr.length; i++) {
        IntentFilter filter = new IntentFilter(filterstr[i]);
        filter.setPriority(100);
        ctx.registerReceiver(this.mReceiver, filter);
        Log.d("SMSPlugin", "broadcast receiver registered for: " + filterstr[i]);
    }
}

From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java

/**
 * //www .ja va2 s .c o m
 * Called when response is received from the server for authentication
 * request. See onAuthenticationResult(). Sets the
 * AccountAuthenticatorResult which is sent back to the caller. Also sets
 * the authToken in AccountManager for this account.
 * 
 * @param the confirmCredentials result.
 */

protected void finishLogin() {
    Log.i(tag, "finishLogin()");
    final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE);

    if (mRequestNewAccount) {
        mAccountManager.addAccountExplicitly(account, mPassword, null);
        mAccountManager.setUserData(account, Constants.PHONE_NUMBER_KEY, countryCode + mPhone);
        // Set contacts sync for this account.
        ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
    } else {
        mAccountManager.setPassword(account, mPassword);
    }
    final Intent intent = new Intent();
    mAuthtoken = mPassword;
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
    if (mAuthtokenType != null && mAuthtokenType.equals(Constants.AUTHTOKEN_TYPE))
        intent.putExtra(AccountManager.KEY_AUTHTOKEN, mAuthtoken);
    Db.deleteServerData(getApplicationContext());
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}

From source file:acceptable_risk.nik.uniobuda.hu.andrawid.util.IabHelper.java

int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras().get(RESPONSE_CODE);
    if (o == null) {
        logError("Intent with no response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {//from ww  w . j  a  v  a 2 s .  c  o  m
        logError("Unexpected type for intent response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}

From source file:com.android.kalite27.ScriptActivity.java

/**
 * When the file pick is finished/*from  w  w  w. ja  v  a  2  s  .  c om*/
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == DirectoryPicker.PICK_DIRECTORY) {
        if (resultCode == RESULT_OK) {
            Bundle extras = data.getExtras();
            String path = (String) extras.get(DirectoryPicker.CHOSEN_DIRECTORY);
            // do stuff with path
            if (check_directory(path)) {
                // if the path is changed
                if (contentPath != path) {
                    // set the local settings
                    mUtilities.setContentPath(path, this);
                    FileTextView.setText("Content location: " + path);
                    FileTextView.setBackgroundColor(Color.parseColor("#A3CC7A"));
                    ServerStatusTextView.setText("Starting server ... ");
                    ServerStatusTextView.setTextColor(Color.parseColor("#005987"));
                    spinner.setVisibility(View.VISIBLE);
                    runScriptService("restart");
                    isFileBrowserClosed = true;
                } else {
                    // TODO: the path is not changed
                    isFileBrowserClosed = true;
                    openWebViewIfAllConditionsMeet();
                }
            }
        } else {
            //exit file browser by pressing back buttom
            isFileBrowserClosed = true;
            openWebViewIfAllConditionsMeet();
        }
    }
}

From source file:edu.mit.mobile.android.locast.accounts.AuthenticatorActivity.java

/**
 *
 * Called when response is received from the server for authentication request. See
 * onAuthenticationResult(). Sets the AccountAuthenticatorResult which is sent back to the
 * caller. Also sets the authToken in AccountManager for this account.
 *
 * @param userData/*from w  w w  . ja va2  s.c o m*/
 *            TODO
 * @param the
 *            confirmCredentials result.
 */

protected void finishLogin(Bundle userData) {
    Log.i(TAG, "finishLogin()");
    // ensure that there isn't a demo account sticking around.

    // TODO this is NOT the place where this code belongs. Find it a better home
    if (Authenticator.isDemoMode(this)) {
        Log.d(TAG, "cleaning up demo mode account...");
        ContentResolver.cancelSync(Authenticator.getFirstAccount(this), MediaProvider.AUTHORITY);

        mAccountManager.removeAccount(
                new Account(Authenticator.DEMO_ACCOUNT, AuthenticationService.ACCOUNT_TYPE),
                new AccountManagerCallback<Boolean>() {

                    @Override
                    public void run(AccountManagerFuture<Boolean> arg0) {
                        try {
                            if (arg0.getResult()) {

                                final ContentValues cv = new ContentValues();
                                // invalidate all the content to force a sync.
                                // this is to ensure that items which were marked favorite get set as
                                // such.
                                cv.put(Cast._SERVER_MODIFIED_DATE, 0);
                                cv.put(Cast._MODIFIED_DATE, 0);
                                getContentResolver().update(Cast.CONTENT_URI, cv, null, null);
                                if (Constants.DEBUG) {
                                    Log.d(TAG, "reset all cast modified dates to force a reload");
                                }
                            }
                        } catch (final OperationCanceledException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (final AuthenticatorException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (final IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }, null);

    }
    final Account account = new Account(mUsername, AuthenticationService.ACCOUNT_TYPE);

    if (mRequestNewAccount) {
        mAccountManager.addAccountExplicitly(account, mPassword, userData);
        // Automatically enable sync for this account
        ContentResolver.setSyncAutomatically(account, MediaProvider.AUTHORITY, true);
    } else {
        mAccountManager.setPassword(account, mPassword);
    }
    final Intent intent = new Intent();
    mAuthtoken = mPassword;
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, AuthenticationService.ACCOUNT_TYPE);
    if (mAuthtokenType != null && mAuthtokenType.equals(AuthenticationService.AUTHTOKEN_TYPE)) {
        intent.putExtra(AccountManager.KEY_AUTHTOKEN, mAuthtoken);
    }
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}