Example usage for android.content Intent EXTRA_STREAM

List of usage examples for android.content Intent EXTRA_STREAM

Introduction

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

Prototype

String EXTRA_STREAM

To view the source code for android.content Intent EXTRA_STREAM.

Click Source Link

Document

A content: URI holding a stream of data associated with the Intent, used with #ACTION_SEND to supply the data being sent.

Usage

From source file:it.feio.android.omninotes.DetailFragment.java

private void handleIntents() {
    Intent i = mainActivity.getIntent();

    if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) {
        noteOriginal = new Note();
        note = new Note(noteOriginal);
        noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE);
        if (i.getStringArrayListExtra("merged_notes") != null) {
            mergedNotesIds = i.getStringArrayListExtra("merged_notes");
        }/*from  w  w  w.  j  a  v a  2s. c o m*/
    }

    // Action called from home shortcut
    if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) {
        afterSavedReturnsToList = false;
        noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0));
        // Checks if the note pointed from the shortcut has been deleted
        try {
            note = new Note(noteOriginal);
            noteTmp = new Note(noteOriginal);
        } catch (NullPointerException e) {
            mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG);
            mainActivity.finish();
        }
    }

    // Check if is launched from a widget
    if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) {

        afterSavedReturnsToList = false;
        showKeyboard = true;

        //  with tags to set tag
        if (i.hasExtra(Constants.INTENT_WIDGET)) {
            String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString();
            if (widgetId != null) {
                String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, "");
                String categoryId = TextHelper.checkIntentCategory(sqlCondition);
                if (categoryId != null) {
                    Category category;
                    try {
                        category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId));
                        noteTmp = new Note();
                        noteTmp.setCategory(category);
                    } catch (NumberFormatException e) {
                        Log.e(Constants.TAG, "Category with not-numeric value!", e);
                    }
                }
            }
        }

        // Sub-action is to take a photo
        if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) {
            takePhoto();
        }
    }

    /**
     * Handles third party apps requests of sharing
     */
    if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE,
            Constants.INTENT_GOOGLE_NOW) && i.getType() != null) {

        afterSavedReturnsToList = false;

        if (noteTmp == null)
            noteTmp = new Note();

        // Text title
        String title = i.getStringExtra(Intent.EXTRA_SUBJECT);
        if (title != null) {
            noteTmp.setTitle(title);
        }

        // Text content
        String content = i.getStringExtra(Intent.EXTRA_TEXT);
        if (content != null) {
            noteTmp.setContent(content);
        }

        // Single attachment data
        Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM);
        // Due to the fact that Google Now passes intent as text but with
        // audio recording attached the case must be handled in specific way
        if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) {
            String name = FileHelper.getNameFromUri(mainActivity, uri);
            AttachmentTask task = new AttachmentTask(this, uri, name, this);
            task.execute();
        }

        // Multiple attachment data
        ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        if (uris != null) {
            for (Uri uriSingle : uris) {
                String name = FileHelper.getNameFromUri(mainActivity, uriSingle);
                AttachmentTask task = new AttachmentTask(this, uriSingle, name, this);
                task.execute();
            }
        }

        //         i.setAction(null);
    }

    if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST)) {
        showKeyboard = true;
    }

}

From source file:com.maskyn.fileeditorpro.activity.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    if (fileOpened && searchResult != null) {
        MenuItem imReplace = menu.findItem(R.id.im_replace);
        MenuItem imReplaceAll = menu.findItem(R.id.im_replace_all);
        MenuItem imPrev = menu.findItem(R.id.im_previous_item);
        MenuItem imNext = menu.findItem(R.id.im_next_item);

        if (imReplace != null)
            imReplace.setVisible(searchResult.canReplaceSomething());

        if (imReplaceAll != null)
            imReplaceAll.setVisible(searchResult.canReplaceSomething());

        if (imPrev != null)
            imPrev.setVisible(searchResult.hasPrevious());

        if (imNext != null)
            imNext.setVisible(searchResult.hasNext());

    } else if (fileOpened) {
        MenuItem imSave = menu.findItem(R.id.im_save);
        MenuItem imUndo = menu.findItem(R.id.im_undo);
        MenuItem imRedo = menu.findItem(R.id.im_redo);

        if (mEditor != null) {
            if (imSave != null)
                imSave.setVisible(mEditor.canSaveFile());
            if (imUndo != null)
                imUndo.setVisible(mEditor.getCanUndo());
            if (imRedo != null)
                imRedo.setVisible(mEditor.getCanRedo());
        } else {/*from w  w w.j  a  v a  2s.com*/
            imSave.setVisible(false);
            imUndo.setVisible(false);
            imRedo.setVisible(false);
        }

        MenuItem imMarkdown = menu.findItem(R.id.im_view_markdown);
        boolean isMarkdown = Arrays.asList(MimeTypes.MIME_MARKDOWN)
                .contains(FilenameUtils.getExtension(greatUri.getFileName()));
        if (imMarkdown != null)
            imMarkdown.setVisible(isMarkdown);

        MenuItem imShare = menu.findItem(R.id.im_share);
        if (imMarkdown != null) {
            ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(imShare);
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_STREAM, greatUri.getUri());
            shareIntent.setType("text/plain");
            shareAction.setShareIntent(shareIntent);
        }
    }

    return true;
}

From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java

/**
 * Export data./*from  w w  w.ja  va2  s  .c o m*/
 * 
 * @param descr
 *            description of the exported rule set
 * @param fn
 *            one of the predefined file names from {@link DataProvider}.
 */
private void exportData(final String descr, final String fn) {
    if (descr == null) {
        final EditText et = new EditText(this);
        Builder builder = new Builder(this);
        builder.setView(et);
        builder.setCancelable(true);
        builder.setTitle(R.string.export_rules_descr);
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, final int which) {
                Preferences.this.exportData(et.getText().toString(), fn);
            }
        });
        builder.show();
    } else {
        final ProgressDialog d = new ProgressDialog(this);
        d.setIndeterminate(true);
        d.setMessage(this.getString(R.string.export_progr));
        d.setCancelable(false);
        d.show();

        // run task in background
        final AsyncTask<Void, Void, String> task = // .
                new AsyncTask<Void, Void, String>() {
                    @Override
                    protected String doInBackground(final Void... params) {
                        if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) {
                            return DataProvider.backupRuleSet(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) {
                            return DataProvider.backupLogs(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) {
                            return DataProvider.backupNumGroups(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) {
                            return DataProvider.backupHourGroups(Preferences.this, descr);
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(final String result) {
                        Log.d(TAG, "export:\n" + result);
                        System.out.println("\n" + result);
                        d.dismiss();
                        if (result != null && result.length() > 0) {
                            Uri uri = null;
                            int resChooser = -1;
                            if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) {
                                uri = DataProvider.EXPORT_RULESET_URI;
                                resChooser = R.string.export_rules_;
                            } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) {
                                uri = DataProvider.EXPORT_LOGS_URI;
                                resChooser = R.string.export_logs_;
                            } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) {
                                uri = DataProvider.EXPORT_NUMGROUPS_URI;
                                resChooser = R.string.export_numgroups_;
                            } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) {
                                uri = DataProvider.EXPORT_HOURGROUPS_URI;
                                resChooser = R.string.export_hourgroups_;
                            }
                            final Intent intent = new Intent(Intent.ACTION_SEND);
                            intent.setType(DataProvider.EXPORT_MIMETYPE);
                            intent.putExtra(Intent.EXTRA_STREAM, uri);
                            intent.putExtra(Intent.EXTRA_SUBJECT, // .
                                    "Call Meter 3G export");
                            intent.addCategory(Intent.CATEGORY_DEFAULT);

                            try {
                                final File d = Environment.getExternalStorageDirectory();
                                final File f = new File(d, DataProvider.PACKAGE + File.separator + fn);
                                f.mkdirs();
                                if (f.exists()) {
                                    f.delete();
                                }
                                f.createNewFile();
                                FileWriter fw = new FileWriter(f);
                                fw.append(result);
                                fw.close();
                                // call an exporting app with the uri to the
                                // preferences
                                Preferences.this.startActivity(
                                        Intent.createChooser(intent, Preferences.this.getString(resChooser)));
                            } catch (IOException e) {
                                Log.e(TAG, "error writing export file", e);
                                Toast.makeText(Preferences.this, R.string.err_export_write, Toast.LENGTH_LONG)
                                        .show();
                            }
                        }
                    }
                };
        task.execute((Void) null);
    }
}

From source file:com.studio.arm.wink.FaceTrackerActivity.java

private void takePicture() {
    mCameraSource.takePicture(null, new CameraSource.PictureCallback() {
        File picture;//from w  ww .j  av a 2 s.c o  m

        @Override
        public void onPictureTaken(byte[] bytes) {
            try {
                Thread.currentThread().sleep((long) (sharedPref.getFloat(FILENAME, 1f) * 1000));

                mPreview.stop();
                picture = null;
                try {
                    picture = FaceFile.savePicture(bytes, "jpg");
                } catch (IOException e) {
                    e.printStackTrace();
                    return;
                }

                new AlertDialog.Builder(FaceTrackerActivity.this).setTitle("Share").setMessage("Share to")
                        .setPositiveButton("Filters", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                Intent shareIntent = new Intent().setPackage("com.vk.snapster");
                                shareIntent.setType("image/jpeg");
                                shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(picture));
                                startActivity(Intent.createChooser(shareIntent, ""));
                            }
                        }).setNegativeButton("Upload", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {

                                new ProgressTask().execute(picture);
                                createCameraSource(flag ? CameraSource.CAMERA_FACING_BACK
                                        : CameraSource.CAMERA_FACING_FRONT);
                                startCameraSource();
                                Message msg = new Message();
                                msg.obj = FACE_NONE;
                                handler.sendMessage(msg);
                            }
                        }).setOnDismissListener(new DialogInterface.OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialog) {
                                createCameraSource(flag ? CameraSource.CAMERA_FACING_BACK
                                        : CameraSource.CAMERA_FACING_FRONT);
                                startCameraSource();
                                Message msg = new Message();
                                msg.obj = FACE_NONE;
                                handler.sendMessage(msg);
                            }
                        }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                createCameraSource(flag ? CameraSource.CAMERA_FACING_BACK
                                        : CameraSource.CAMERA_FACING_FRONT);
                                startCameraSource();
                                Message msg = new Message();
                                msg.obj = FACE_NONE;
                                handler.sendMessage(msg);
                            }
                        }).setIcon(android.R.drawable.ic_dialog_alert).show();
            } catch (InterruptedException e) {
            } catch (RuntimeException r) {
                Log.d("Errorrrrrrrr", "RuntimeError");
            }
        }
    });

}

From source file:com.synox.android.ui.activity.Uploader.java

private void prepareStreamsToUpload() {
    try {//from  w ww  . j a v  a  2s  .co  m
        if (getIntent().getAction().equals(Intent.ACTION_SEND)) {
            mStreamsToUpload = new ArrayList<>();
            mStreamsToUpload.add(getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
        } else if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
            mStreamsToUpload = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        }
    } catch (NullPointerException npe) {
        Log_OC.e(this.getClass().getName(), "Unknown error occurred. Message: " + npe.getLocalizedMessage());
    }
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

public void shareComicImage() {
    if (comicInfo == null || comicInfo.getImage() == null) {
        toast("No image loaded.");
        return;/*from  ww w. j  a  v a2s  .c o  m*/
    }

    new Utility.CancellableAsyncTaskWithProgressDialog<Uri, File>(getStringAppName()) {
        Throwable e;

        @Override
        protected File doInBackground(Uri... params) {
            try {
                File file = new File(getApplicationContext().getExternalCacheDir(),
                        comicDef.getComicTitleAbbrev() + "-" + params[0].getLastPathSegment());
                Utility.blockingSaveFile(file, params[0]);
                return file;

            } catch (InterruptedException ex) {
                return null;
            } catch (Throwable ex) {
                e = ex;
                return null;
            }
        }

        @Override
        protected void onPostExecute(File result) {
            super.onPostExecute(result);
            if (result != null && e == null) {

                try {
                    Uri uri = Uri.fromFile(result);
                    Intent intent = new Intent(Intent.ACTION_SEND, null);
                    intent.setType(Utility.getContentType(uri));
                    intent.putExtra(Intent.EXTRA_STREAM, uri);
                    startActivity(Intent.createChooser(intent, "Share image..."));
                    return;
                } catch (MalformedURLException ex) {
                    e = ex;
                } catch (IOException ex) {
                    e = ex;
                }
            }
            e.printStackTrace();
            failed("Couldn't save attachment: " + e);
        }

    }.start(this, "Saving image...", new Uri[] { comicInfo.getImage() });
}

From source file:com.cerema.cloud2.ui.activity.Uploader.java

private void prepareStreamsToUpload() {
    if (getIntent().getAction().equals(Intent.ACTION_SEND)) {
        mStreamsToUpload = new ArrayList<Parcelable>();
        mStreamsToUpload.add(getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
    } else if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
        mStreamsToUpload = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    }/*  ww  w .j a  v  a 2s  . com*/
}

From source file:com.owncloud.android.ui.activity.ReceiveExternalFilesActivity.java

private void prepareStreamsToUpload() {
    if (getIntent().getAction().equals(Intent.ACTION_SEND)) {
        mStreamsToUpload = new ArrayList<>();
        mStreamsToUpload.add(getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
        if (mStreamsToUpload.get(0) != null) {
            String streamToUpload = mStreamsToUpload.get(0).toString();
            if (streamToUpload.contains("/data") && streamToUpload.contains(getPackageName())
                    && !streamToUpload.contains(getCacheDir().getPath())) {
                finish();//from  w w w .j  a v  a2  s .c o m
            }
        }
    } else if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
        mStreamsToUpload = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    }
}

From source file:com.dycody.android.idealnote.DetailFragment.java

private void handleIntents() {
    Intent i = mainActivity.getIntent();

    if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) {
        noteOriginal = new Note();
        note = new Note(noteOriginal);
        noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE);
        if (i.getStringArrayListExtra("merged_notes") != null) {
            mergedNotesIds = i.getStringArrayListExtra("merged_notes");
        }//from   w  w w  .j a v  a2 s. c  o m
    }

    // Action called from home shortcut
    if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) {
        afterSavedReturnsToList = false;
        noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0));
        // Checks if the note pointed from the shortcut has been deleted
        try {
            note = new Note(noteOriginal);
            noteTmp = new Note(noteOriginal);
        } catch (NullPointerException e) {
            mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG);
            mainActivity.finish();
        }
    }

    // Check if is launched from a widget
    if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) {

        afterSavedReturnsToList = false;
        showKeyboard = true;

        //  with tags to set tag
        if (i.hasExtra(Constants.INTENT_WIDGET)) {
            String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString();
            if (widgetId != null) {
                String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, "");
                String categoryId = TextHelper.checkIntentCategory(sqlCondition);
                if (categoryId != null) {
                    Category category;
                    try {
                        category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId));
                        noteTmp = new Note();
                        noteTmp.setCategory(category);
                    } catch (NumberFormatException e) {
                        Log.e(Constants.TAG, "Category with not-numeric value!", e);
                    }
                }
            }
        }

        // Sub-action is to take a photo
        if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) {
            takePhoto();
        }
    }

    /**
     * Handles third party apps requests of sharing
     */
    if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE,
            Constants.INTENT_GOOGLE_NOW) && i.getType() != null) {

        afterSavedReturnsToList = false;

        if (noteTmp == null)
            noteTmp = new Note();

        // Text title
        String title = i.getStringExtra(Intent.EXTRA_SUBJECT);
        if (title != null) {
            noteTmp.setTitle(title);
        }

        // Text content
        String content = i.getStringExtra(Intent.EXTRA_TEXT);
        if (content != null) {
            noteTmp.setContent(content);
        }

        // Single attachment data
        Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM);
        // Due to the fact that Google Now passes intent as text but with
        // audio recording attached the case must be handled in specific way
        if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) {
            String name = FileHelper.getNameFromUri(mainActivity, uri);
            new AttachmentTask(this, uri, name, this).execute();
        }

        // Multiple attachment data
        ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        if (uris != null) {
            for (Uri uriSingle : uris) {
                String name = FileHelper.getNameFromUri(mainActivity, uriSingle);
                new AttachmentTask(this, uriSingle, name, this).execute();
            }
        }
    }

    if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST,
            Constants.ACTION_SHORTCUT_WIDGET, Constants.ACTION_WIDGET)) {
        showKeyboard = true;
    }

    i.setAction(null);
}

From source file:de.ub0r.android.websms.WebSMS.java

/**
 * Parse data pushed by {@link Intent}.//ww  w .  ja va  2 s. co  m
 *
 * @param intent {@link Intent}
 */
private void parseIntent(final Intent intent) {
    final String action = intent.getAction();
    Log.d(TAG, "launched with action: " + action);
    if (action == null) {
        return;
    }
    final Uri uri = intent.getData();
    Log.i(TAG, "launched with uri: " + uri);
    if (uri != null && uri.toString().length() > 0) {
        // launched by clicking a sms: link, target number is in URI.
        final String scheme = uri.getScheme();
        if (scheme != null) {
            if (scheme.equals("sms") || scheme.equals("smsto")) {
                final String s = uri.getSchemeSpecificPart();
                this.parseSchemeSpecificPart(s);
            } else if (scheme.equals("content")) {
                this.parseThreadId(uri.getLastPathSegment());
            }
        }
    }
    // check for extras
    String s = intent.getStringExtra("address");
    if (!TextUtils.isEmpty(s)) {
        Log.d(TAG, "got address: " + s);
        this.lastTo = s;
    }
    s = intent.getStringExtra(Intent.EXTRA_TEXT);
    if (s == null) {
        Log.d(TAG, "got sms_body: " + s);
        s = intent.getStringExtra("sms_body");
    }
    if (s == null) {
        final Uri stream = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
        if (stream != null) {
            Log.d(TAG, "got stream: " + stream);
            try {
                InputStream is = this.getContentResolver().openInputStream(stream);
                final BufferedReader r = new BufferedReader(new InputStreamReader(is));
                StringBuffer sb = new StringBuffer();
                String line;
                while ((line = r.readLine()) != null) {
                    sb.append(line + "\n");
                }
                s = sb.toString().trim();
            } catch (IOException e) {
                Log.e(TAG, "IO ERROR", e);
            }

        }
    }
    if (s != null) {
        Log.d(TAG, "set text: " + s);
        ((EditText) this.findViewById(R.id.text)).setText(s);
        this.lastMsg = s;
    }
    s = intent.getStringExtra(EXTRA_ERRORMESSAGE);
    if (s != null) {
        Log.e(TAG, "show error: " + s);
        Toast.makeText(this, s, Toast.LENGTH_LONG).show();
    }
    final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
    if (p.getBoolean(PREFS_AUTOSEND, true)) {
        s = intent.getStringExtra(WebSMS.EXTRA_AUTOSEND);
        Log.d(TAG, "try autosend..");
        Log.d(TAG, "s: " + s);
        Log.d(TAG, "lastMsg: " + this.lastMsg);
        Log.d(TAG, "lastTo: " + this.lastTo);

        if (s != null && !TextUtils.isEmpty(this.lastMsg) && !TextUtils.isEmpty(this.lastTo)) {
            // all data is here
            Log.d(TAG, "do autosend");
            if (p.getBoolean(PREFS_USE_CURRENT_CON, true)) {
                // push it to current active connector
                Log.d(TAG, "use current connector");
                if (prefsConnectorSpec != null && prefsSubConnectorSpec != null) {
                    Log.d(TAG, "autosend: call send()");
                    if (this.send(prefsConnectorSpec, prefsSubConnectorSpec) && !this.isFinishing()) {
                        Log.d(TAG, "sent successfully");
                        this.finish();
                    }
                }
            } else {
                // show connector chooser
                Log.d(TAG, "show connector chooser");
                final AlertDialog.Builder b = new AlertDialog.Builder(this);
                b.setTitle(R.string.change_connector_);
                final ConnectorLabel[] items = this.getConnectorMenuItems(true /*isIncludePseudoConnectors*/);
                Log.d(TAG, "show #items: " + items.length);
                if (items.length > 0) {
                    b.setItems(items, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int which) {
                            final ConnectorLabel sel = items[which];
                            // save old selected connector
                            final ConnectorSpec pr0 = prefsConnectorSpec;
                            final SubConnectorSpec pr1 = prefsSubConnectorSpec;
                            // switch to selected
                            WebSMS.this.saveSelectedConnector(sel.getConnector(), sel.getSubConnector());
                            // send message
                            boolean sent = false;
                            Log.d(TAG, "autosend: call send()");
                            if (prefsConnectorSpec != null && prefsSubConnectorSpec != null) {
                                sent = WebSMS.this.send(prefsConnectorSpec, prefsSubConnectorSpec);
                            }
                            // restore old connector
                            WebSMS.this.saveSelectedConnector(pr0, pr1);
                            // quit
                            if (sent && !WebSMS.this.isFinishing()) {
                                Log.d(TAG, "sent successfully");
                                WebSMS.this.finish();
                            }
                        }
                    });
                    b.setNegativeButton(android.R.string.cancel, null);
                    b.show();
                }
            }
        }
    }
}