Example usage for android.content Intent EXTRA_TEXT

List of usage examples for android.content Intent EXTRA_TEXT

Introduction

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

Prototype

String EXTRA_TEXT

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

Click Source Link

Document

A constant CharSequence that is associated with the Intent, used with #ACTION_SEND to supply the literal data to be sent.

Usage

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

/**
 * {@inheritDoc}/*from   w  w w  .  jav  a 2  s  .c o m*/
 */
@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.setLocale(this);
    this.setTitle(R.string.settings);
    this.addPreferencesFromResource(R.xml.prefs);

    Preference p = this.findPreference(PREFS_ADVANCED);
    if (p != null) {
        p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(final Preference preference, final Object newValue) {
                if (newValue.equals(true)) {
                    Preferences.this.startActivity(new Intent(Preferences.this, Help.class));
                }
                return true;
            }
        });
    }
    Market.setOnPreferenceClickListener(this, this.findPreference("more_apps"), null, "Felix+Bechstein",
            "http://code.google.com/u/felix.bechstein/");
    p = this.findPreference("send_logs");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    public boolean onPreferenceClick(final Preference preference) {
                        Log.collectAndSendLog(Preferences.this);
                        return true;
                    }
                });
    }
    p = this.findPreference("send_devices");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    @Override
                    public boolean onPreferenceClick(final Preference preference) {
                        final Intent intent = new Intent(// .
                                Intent.ACTION_SEND);
                        intent.setType("text/plain");
                        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "android+callmeter@ub0r.de", "" });
                        intent.putExtra(Intent.EXTRA_TEXT, Device.debugDeviceList());
                        intent.putExtra(Intent.EXTRA_SUBJECT, "Call Meter 3G: Device List");
                        try {
                            Preferences.this.startActivity(intent);
                        } catch (ActivityNotFoundException e) {
                            Log.e(TAG, "no mail", e);
                            Toast.makeText(Preferences.this, "no mail app found", Toast.LENGTH_LONG).show();
                        }
                        return true;
                    }
                });
    }
    p = this.findPreference("reset_data");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    public boolean onPreferenceClick(final Preference preference) {
                        Preferences.this.resetDataDialog();
                        return true;
                    }
                });
    }
    p = this.findPreference("export_rules");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    public boolean onPreferenceClick(final Preference preference) {
                        Preferences.this.exportData(null, DataProvider.EXPORT_RULESET_FILE);
                        return true;
                    }
                });
    }
    p = this.findPreference("export_logs");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    public boolean onPreferenceClick(final Preference preference) {
                        Preferences.this.exportData(null, DataProvider.EXPORT_LOGS_FILE);
                        return true;
                    }
                });
    }
    p = this.findPreference("export_numgroups");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    public boolean onPreferenceClick(final Preference preference) {
                        Preferences.this.exportData(null, DataProvider.EXPORT_NUMGROUPS_FILE);
                        return true;
                    }
                });
    }
    p = this.findPreference("export_hourgroups");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    public boolean onPreferenceClick(final Preference preference) {
                        Preferences.this.exportData(null, DataProvider.EXPORT_HOURGROUPS_FILE);
                        return true;
                    }
                });
    }
    p = this.findPreference("import_rules");
    if (p != null) {
        p.setOnPreferenceClickListener(// .
                new Preference.OnPreferenceClickListener() {
                    public boolean onPreferenceClick(final Preference preference) {
                        Preferences.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(// .
                                Preferences.this.getString(// .
                                        R.string.url_rulesets))));
                        return true;
                    }
                });
    }

    this.onNewIntent(this.getIntent());
}

From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java

private void sentGenericText(String subject, String msg) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, msg);
    startActivity(intent);//from   w  ww. j a v  a2s  .  c om
}

From source file:com.ichi2.anki.NoteEditor.java

private void fetchIntentInformation(Intent intent) {
    Bundle extras = intent.getExtras();/*from ww  w. ja  v a  2s.  co  m*/
    if (ACTION_CREATE_FLASHCARD.equals(intent.getAction())) {
        // mSourceLanguage = extras.getString(SOURCE_LANGUAGE);
        // mTargetLanguage = extras.getString(TARGET_LANGUAGE);
        mSourceText = new String[2];
        mSourceText[0] = extras.getString(SOURCE_TEXT);
        mSourceText[1] = extras.getString(TARGET_TEXT);
    } else {
        String first;
        String second;
        if (extras.getString(Intent.EXTRA_SUBJECT) != null) {
            first = extras.getString(Intent.EXTRA_SUBJECT);
        } else {
            first = "";
        }
        if (extras.getString(Intent.EXTRA_TEXT) != null) {
            second = extras.getString(Intent.EXTRA_TEXT);
        } else {
            second = "";
        }
        // Some users add cards via SEND intent from clipboard. In this case SUBJECT is empty
        if (first.equals("")) {
            // Assume that if only one field was sent then it should be the front
            first = second;
            second = "";
        }
        Pair<String, String> messages = new Pair<String, String>(first, second);

        mSourceText = new String[2];
        mSourceText[0] = messages.first;
        mSourceText[1] = messages.second;
    }
}

From source file:com.ibuildapp.romanblack.WebPlugin.WebPlugin.java

@Override
public void create() {
    try {/*from  ww  w.  j  a v  a2 s. com*/

        setContentView(R.layout.romanblack_html_main);
        root = (FrameLayout) findViewById(R.id.romanblack_root_layout);
        webView = new ObservableWebView(this);
        webView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                RelativeLayout.LayoutParams.MATCH_PARENT));
        root.addView(webView);

        webView.setHorizontalScrollBarEnabled(false);
        setTitle("HTML");

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

        if (widget.getPluginXmlData().length() == 0) {
            if (currentIntent.getStringExtra("WidgetFile").length() == 0) {
                handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
                return;
            }
        }

        if (widget.getTitle() != null && widget.getTitle().length() > 0) {
            setTopBarTitle(widget.getTitle());
        } else {
            setTopBarTitle(getResources().getString(R.string.romanblack_html_web));
        }

        currentUrl = (String) getSession();
        if (currentUrl == null) {
            currentUrl = "";
        }

        ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getActiveNetworkInfo();
        if (ni != null && ni.isConnectedOrConnecting()) {
            isOnline = true;
        }

        // topbar initialization
        setTopBarLeftButtonText(getString(R.string.common_home_upper), true, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });

        if (isOnline) {
            webView.getSettings().setJavaScriptEnabled(true);
        }

        webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        webView.getSettings().setGeolocationEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setAppCacheEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setUseWideViewPort(false);
        webView.getSettings().setSavePassword(false);
        webView.clearHistory();
        webView.invalidate();

        if (Build.VERSION.SDK_INT >= 19) {
        }
        webView.getSettings().setUserAgentString(
                "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");

        webView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                v.invalidate();

                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN: {
                }
                    break;
                case MotionEvent.ACTION_UP: {
                    if (!v.hasFocus()) {
                        v.requestFocus();
                    }
                }
                    break;

                case MotionEvent.ACTION_MOVE: {
                }
                    break;

                }
                return false;
            }
        });

        webView.setBackgroundColor(Color.WHITE);
        try {
            if (widget.getBackgroundColor() != Color.TRANSPARENT) {
                webView.setBackgroundColor(widget.getBackgroundColor());
            }
        } catch (IllegalArgumentException e) {
        }

        webView.setDownloadListener(new DownloadListener() {
            @Override
            public void onDownloadStart(String url, String userAgent, String contentDisposition,
                    String mimetype, long contentLength) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
            }
        });

        webView.setWebChromeClient(new WebChromeClient() {

            FrameLayout.LayoutParams LayoutParameters = new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);

            @Override
            public void onGeolocationPermissionsShowPrompt(final String origin,
                    final GeolocationPermissions.Callback callback) {
                AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this);
                builder.setTitle(R.string.location_dialog_title);
                builder.setMessage(R.string.location_dialog_description);
                builder.setCancelable(true);

                builder.setPositiveButton(R.string.location_dialog_allow,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                callback.invoke(origin, true, false);
                            }
                        });

                builder.setNegativeButton(R.string.location_dialog_not_allow,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                callback.invoke(origin, false, false);
                            }
                        });

                AlertDialog alert = builder.create();
                alert.show();
            }

            @Override
            public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
                if (customView != null) {
                    customViewCallback.onCustomViewHidden();
                    return;
                }

                view.setBackgroundColor(Color.BLACK);
                view.setLayoutParams(LayoutParameters);
                root.addView(view);
                customView = view;
                customViewCallback = callback;
                webView.setVisibility(View.GONE);
            }

            @Override
            public void onHideCustomView() {
                if (customView == null) {
                    return;
                } else {
                    closeFullScreenVideo();
                }
            }

            public void openFileChooser(ValueCallback<Uri> uploadMsg) {

                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);//Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                isMedia = true;
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);

            }

            // For Android 3.0+
            public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("*/*");
                startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
            }

            //For Android 4.1
            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                isMedia = true;
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);

            }

            @Override
            public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
                    FileChooserParams fileChooserParams) {
                isV21 = true;
                mUploadMessageV21 = filePathCallback;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
                return true;
            }

            @Override
            public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
                super.onReceivedTouchIconUrl(view, url, precomposed);
            }
        });

        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);

                if (state == states.EMPTY) {
                    currentUrl = url;
                    setSession(currentUrl);
                    state = states.LOAD_START;
                    handler.sendEmptyMessage(SHOW_PROGRESS);
                }
            }

            @Override
            public void onLoadResource(WebView view, String url) {

                if (!alreadyLoaded
                        && (url.startsWith("http://www.youtube.com/get_video_info?")
                                || url.startsWith("https://www.youtube.com/get_video_info?"))
                        && Build.VERSION.SDK_INT < 11) {
                    try {
                        String path = url.contains("https://www.youtube.com/get_video_info?")
                                ? url.replace("https://www.youtube.com/get_video_info?", "")
                                : url.replace("http://www.youtube.com/get_video_info?", "");

                        String[] parqamValuePairs = path.split("&");

                        String videoId = null;

                        for (String pair : parqamValuePairs) {
                            if (pair.startsWith("video_id")) {
                                videoId = pair.split("=")[1];
                                break;
                            }
                        }

                        if (videoId != null) {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com"))
                                    .setData(Uri.parse("http://www.youtube.com/watch?v=" + videoId)));
                            needRefresh = true;
                            alreadyLoaded = !alreadyLoaded;

                            return;
                        }
                    } catch (Exception ex) {
                    }
                } else {
                    super.onLoadResource(view, url);
                }
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                if (hideProgress) {
                    if (TextUtils.isEmpty(WebPlugin.this.url)) {
                        state = states.LOAD_COMPLETE;
                        handler.sendEmptyMessage(HIDE_PROGRESS);
                        super.onPageFinished(view, url);
                    } else {
                        view.loadUrl("javascript:(function(){" + "l=document.getElementById('link');"
                                + "e=document.createEvent('HTMLEvents');" + "e.initEvent('click',true,true);"
                                + "l.dispatchEvent(e);" + "})()");
                        hideProgress = false;
                    }
                } else {
                    state = states.LOAD_COMPLETE;
                    handler.sendEmptyMessage(HIDE_PROGRESS);
                    super.onPageFinished(view, url);
                }
            }

            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                if (errorCode == WebViewClient.ERROR_BAD_URL) {
                    startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)),
                            DOWNLOAD_REQUEST_CODE);
                }
            }

            @Override
            public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
                final AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this);
                builder.setMessage(R.string.notification_error_ssl_cert_invalid);
                builder.setPositiveButton(WebPlugin.this.getResources().getString(R.string.wp_continue),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                handler.proceed();
                            }
                        });
                builder.setNegativeButton(WebPlugin.this.getResources().getString(R.string.wp_cancel),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                handler.cancel();
                            }
                        });
                final AlertDialog dialog = builder.create();
                dialog.show();
            }

            @Override
            public void onFormResubmission(WebView view, Message dontResend, Message resend) {
                super.onFormResubmission(view, dontResend, resend);
            }

            @Override
            public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
                return super.shouldInterceptRequest(view, request);
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                try {

                    if (url.contains("youtube.com/watch")) {
                        if (Build.VERSION.SDK_INT < 11) {
                            try {
                                startActivity(
                                        new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com"))
                                                .setData(Uri.parse(url)));
                                return true;
                            } catch (Exception ex) {
                                return false;
                            }
                        } else {
                            return false;
                        }
                    } else if (url.contains("paypal.com")) {
                        if (url.contains("&bn=ibuildapp_SP")) {
                            return false;
                        } else {
                            url = url + "&bn=ibuildapp_SP";

                            webView.loadUrl(url);

                            return true;
                        }
                    } else if (url.contains("sms:")) {
                        try {
                            Intent smsIntent = new Intent(Intent.ACTION_VIEW);
                            smsIntent.setData(Uri.parse(url));
                            startActivity(smsIntent);
                            return true;
                        } catch (Exception ex) {
                            Log.e("", ex.getMessage());
                            return false;
                        }
                    } else if (url.contains("tel:")) {
                        Intent callIntent = new Intent(Intent.ACTION_CALL);
                        callIntent.setData(Uri.parse(url));
                        startActivity(callIntent);
                        return true;
                    } else if (url.contains("mailto:")) {
                        MailTo mailTo = MailTo.parse(url);

                        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                        emailIntent.setType("plain/text");
                        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                                new String[] { mailTo.getTo() });

                        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mailTo.getSubject());
                        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, mailTo.getBody());
                        WebPlugin.this.startActivity(Intent.createChooser(emailIntent,
                                getString(R.string.romanblack_html_send_email)));
                        return true;
                    } else if (url.contains("rtsp:")) {
                        Uri address = Uri.parse(url);
                        Intent intent = new Intent(Intent.ACTION_VIEW, address);

                        final PackageManager pm = getPackageManager();
                        final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0);
                        if (matches.size() > 0) {
                            startActivity(intent);
                        } else {
                            Toast.makeText(WebPlugin.this, getString(R.string.romanblack_html_no_video_player),
                                    Toast.LENGTH_SHORT).show();
                        }

                        return true;
                    } else if (url.startsWith("intent:") || url.startsWith("market:")
                            || url.startsWith("col-g2m-2:")) {
                        Intent it = new Intent();
                        it.setData(Uri.parse(url));
                        startActivity(it);

                        return true;
                    } else if (url.contains("//play.google.com/")) {
                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                        return true;
                    } else {
                        if (url.contains("ibuildapp.com-1915109")) {
                            String param = Uri.parse(url).getQueryParameter("widget");
                            finish();
                            if (param != null && param.equals("1001"))
                                com.appbuilder.sdk.android.Statics.launchMain();
                            else if (param != null && !"".equals(param)) {
                                View.OnClickListener widget = Statics.linkWidgets.get(Integer.valueOf(param));
                                if (widget != null)
                                    widget.onClick(view);
                            }
                            return false;
                        }

                        currentUrl = url;
                        setSession(currentUrl);
                        if (!isOnline) {
                            handler.sendEmptyMessage(HIDE_PROGRESS);
                            handler.sendEmptyMessage(STOP_LOADING);
                        } else {
                            String pageType = "application/html";
                            if (!url.contains("vk.com")) {
                                getPageType(url);
                            }
                            if (pageType.contains("application") && !pageType.contains("html")
                                    && !pageType.contains("xml")) {
                                startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)),
                                        DOWNLOAD_REQUEST_CODE);
                                return super.shouldOverrideUrlLoading(view, url);
                            } else {
                                view.getSettings().setLoadWithOverviewMode(true);
                                view.getSettings().setUseWideViewPort(true);
                                view.setBackgroundColor(Color.WHITE);
                            }
                        }
                        return false;
                    }

                } catch (Exception ex) { // Error Logging
                    return false;
                }
            }
        });

        handler.sendEmptyMessage(SHOW_PROGRESS);

        new Thread() {
            @Override
            public void run() {

                EntityParser parser;
                if (widget.getPluginXmlData() != null) {
                    if (widget.getPluginXmlData().length() > 0) {
                        parser = new EntityParser(widget.getPluginXmlData());
                    } else {
                        String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile"));
                        parser = new EntityParser(xmlData);
                    }
                } else {
                    String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile"));
                    parser = new EntityParser(xmlData);
                }

                parser.parse();

                url = parser.getUrl();
                html = parser.getHtml();

                if (url.length() > 0 && !isOnline) {
                    handler.sendEmptyMessage(NEED_INTERNET_CONNECTION);
                } else {
                    if (isOnline) {
                    } else {
                        if (html.length() == 0) {
                        }
                    }
                    if (html.length() > 0 || url.length() > 0) {
                        handler.sendEmptyMessageDelayed(SHOW_HTML, 700);
                    } else {
                        handler.sendEmptyMessage(HIDE_PROGRESS);
                        handler.sendEmptyMessage(INITIALIZATION_FAILED);
                    }
                }
            }
        }.start();

    } catch (Exception ex) {
    }
}

From source file:com.hichinaschool.flashcards.anki.CardEditor.java

private void fetchIntentInformation(Intent intent) {
    Bundle extras = intent.getExtras();// w  ww .j a v a2  s  .c o  m
    if (ACTION_CREATE_FLASHCARD.equals(intent.getAction())) {
        // mSourceLanguage = extras.getString(SOURCE_LANGUAGE);
        // mTargetLanguage = extras.getString(TARGET_LANGUAGE);
        mSourceText = new String[2];
        mSourceText[0] = extras.getString(SOURCE_TEXT);
        mSourceText[1] = extras.getString(TARGET_TEXT);
    } else {
        String first;
        String second;
        if (extras.getString(Intent.EXTRA_SUBJECT) != null) {
            first = extras.getString(Intent.EXTRA_SUBJECT);
        } else {
            first = "";
        }
        if (extras.getString(Intent.EXTRA_TEXT) != null) {
            second = extras.getString(Intent.EXTRA_TEXT);
        } else {
            second = "";
        }
        Pair<String, String> messages = new Pair<String, String>(first, second);

        /* Filter garbage information */
        Pair<String, String> cleanMessages = new FilterFacade(getBaseContext()).filter(messages);

        mSourceText = new String[2];
        mSourceText[0] = cleanMessages.first;
        mSourceText[1] = cleanMessages.second;
    }
}

From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java

/**
 * /** Used to shared what the user is currently listening to
 *//*from  w w w .j  a  v  a2 s.c  o m*/
private void shareCurrentTrack() {
    if (MusicUtils.getTrackName() == null || MusicUtils.getArtistName() == null) {
        return;
    }
    final Intent shareIntent = new Intent();
    final String shareMessage = getString(R.string.now_listening_to) + " " + MusicUtils.getTrackName() + " "
            + getString(R.string.by) + " " + MusicUtils.getArtistName() + " " + getString(R.string.hash_apollo);

    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
    startActivity(Intent.createChooser(shareIntent, getString(R.string.share_track_using)));
}

From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java

void init() {

    //        img=(ImageView)findViewById(R.id.logo);

    TextView build = (TextView) findViewById(R.id.checkfornew);
    build.setOnClickListener(new View.OnClickListener() {
        @Override//from   w  ww  .j  a  v  a 2  s .c  om
        public void onClick(View v) {
            if (android.os.Build.VERSION.SDK_INT > 9) {
                StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
                StrictMode.setThreadPolicy(policy);
            }

            CommonUtilities.logMe("about to check for version ");
            try {
                WebServiceHandler wsb = new WebServiceHandler();
                ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
                String result = wsb.getWebServiceData("http://doe.emergencyskills.com/api/version.php",
                        postParameters);
                JSONObject jsonObject = new JSONObject(result);
                String version = jsonObject.getString("version");
                String features = jsonObject.getString("features");
                System.err.println("version is : " + version);
                if (!LoginActivity.myversion.equals(version)) {
                    MyToast.popmessagelong(
                            "There is a new build available. Please download for these features: " + features,
                            TabsActivity.this);
                    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vireo.org/esiapp"));
                    browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(browserIntent);
                } else {
                    MyToast.popmessagelong("You have the most current version!", TabsActivity.this);
                }
            } catch (Exception exc) {
                exc.printStackTrace();
            }

        }
    });

    TextView maillog = (TextView) findViewById(R.id.maillog);
    maillog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            final Dialog dialog = new Dialog(TabsActivity.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.dialog_logout);

            TextView question = (TextView) dialog.findViewById(R.id.question);
            question.setText("Are you sure you want to email the log?");
            TextView extra = (TextView) dialog.findViewById(R.id.extratext);
            extra.setText("");

            dialog.getWindow().setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(android.R.color.transparent)));
            Button yes = (Button) dialog.findViewById(R.id.yesbtn);
            yes.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent i = new Intent(Intent.ACTION_SEND);
                    i.setType("message/rfc822");
                    i.putExtra(Intent.EXTRA_EMAIL, new String[] { "rachelc@gmail.com" });
                    i.putExtra(Intent.EXTRA_SUBJECT, "Sending Log");
                    i.putExtra(Intent.EXTRA_TEXT, "body of email");
                    try {
                        startActivity(Intent.createChooser(i, "Send mail..."));
                    } catch (android.content.ActivityNotFoundException ex) {
                        Toast.makeText(TabsActivity.this, "There are no email clients installed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    finish();
                }
            });
            Button no = (Button) dialog.findViewById(R.id.nobtn);
            no.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            ImageView close = (ImageView) dialog.findViewById(R.id.ivClose);
            close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });

            dialog.show();

        }
    });

    listops listops = new listops(TabsActivity.this);
    CommonUtilities.logMe("logging in as: " + listops.getString("firstname"));
    TextView name = (TextView) findViewById(R.id.welcome);
    name.setText("Welcome, " + listops.getString("firstname"));

    TextView logoutname = (TextView) findViewById(R.id.logoutname);
    logoutname.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(TabsActivity.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.dialog_logout);
            dialog.getWindow().setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(android.R.color.transparent)));
            dialog.setContentView(R.layout.dialog_logout);
            Button yes = (Button) dialog.findViewById(R.id.yesbtn);
            yes.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    MyToast.popmessagelong("Logging out... ", TabsActivity.this);
                    SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putString(Constants.loginkey, "");
                    editor.commit();
                    listops listops = new listops(TabsActivity.this);
                    //make sure to remove the downloaded schools

                    Intent intent = new Intent(TabsActivity.this, LoginActivity.class);
                    startActivity(intent);
                    ArrayList<Schoolinfomodel> ls = new ArrayList<Schoolinfomodel>();
                    listops.putdrilllist(ls);
                    listops.putservicelist(ls);
                    listops.putinstallllist(ls);
                    ArrayList<PendingUploadModel> l = new ArrayList<PendingUploadModel>();
                    listops.putpendinglist(l);

                    finish();
                }
            });
            Button no = (Button) dialog.findViewById(R.id.nobtn);
            no.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            ImageView close = (ImageView) dialog.findViewById(R.id.ivClose);
            close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });

            dialog.show();
        }

    });

    ll1 = (LinearLayout) findViewById(R.id.ll1);
    ll2 = (LinearLayout) findViewById(R.id.ll2);
    ll3 = (LinearLayout) findViewById(R.id.ll3);
    ll4 = (LinearLayout) findViewById(R.id.ll4);
    ll5 = (LinearLayout) findViewById(R.id.ll5);
    ll6 = (LinearLayout) findViewById(R.id.ll6);
    ll1.setBackgroundColor(getResources().getColor(R.color.White));

    llPickSchools = (LinearLayout) findViewById(R.id.llPickSchool);
    llDrills = (LinearLayout) findViewById(R.id.llDrills);
    llServiceCalls = (LinearLayout) findViewById(R.id.llServiceCalls);
    llNewInstalls = (LinearLayout) findViewById(R.id.llNewInstalls);
    llPendingUploads = (LinearLayout) findViewById(R.id.llPendingUploads);

    frameLayout = (FrameLayout) findViewById(R.id.frame);

}

From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java

private void shareLink() {
    GalleryItemViewTag tag = getCurrentTag();
    if (tag == null)
        return;//from  ww  w .j a v  a 2  s .co m
    String absoluteUrl = remote.getAbsoluteUrl(tag.attachmentModel.path);
    if (absoluteUrl == null)
        return;
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, absoluteUrl);
    shareIntent.putExtra(Intent.EXTRA_TEXT, absoluteUrl);
    startActivity(Intent.createChooser(shareIntent, getString(R.string.share_via)));
}

From source file:fi.mikuz.boarder.gui.DropboxMenu.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_share:
        Thread thread = new Thread() {
            public void run() {
                Looper.prepare();/*from   ww  w.  ja va2s . c o m*/
                try {
                    final ArrayList<String> boards = mCbla.getAllSelectedTitles();
                    if (!(mOperation == DOWNLOAD_OPERATION)) {
                        mToastMessage = "Select 'Download' mode";
                        mHandler.post(mShowToast);
                    } else if (boards.size() < 1) {
                        mToastMessage = "Select boards to share";
                        mHandler.post(mShowToast);
                    } else {
                        String shareString = "I want to share some cool soundboards to you!\n\n"
                                + "To use the boards you need to have Boarder for Android:\n"
                                + ExternalIntent.mExtLinkMarket + "\n\n" + "Here are the boards:\n";

                        for (String board : boards) {
                            shareString += board + " - " + mApi.createCopyRef("/" + board).copyRef + "\n";
                        }

                        shareString += "\n\n" + "Importing a board:\n" + "1. Open Boarder'\n"
                                + "2. Open Dropbox from menu in 'Soundboard Menu'\n"
                                + "3. Open 'Import share' from menu\n"
                                + "4. Copy a reference from above to textfield\n";

                        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                        sharingIntent.setType("text/plain");
                        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sharing boards");
                        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareString);
                        startActivity(Intent.createChooser(sharingIntent, "Share via"));
                    }
                } catch (DropboxException e) {
                    Log.e(TAG, "Unable to share", e);
                }
            }
        };
        thread.start();
        return true;

    case R.id.menu_import_share:
        LayoutInflater removeInflater = (LayoutInflater) DropboxMenu.this
                .getSystemService(LAYOUT_INFLATER_SERVICE);
        View importLayout = removeInflater.inflate(R.layout.dropbox_menu_alert_import_share,
                (ViewGroup) findViewById(R.id.alert_remove_sound_root));

        AlertDialog.Builder importBuilder = new AlertDialog.Builder(DropboxMenu.this);
        importBuilder.setView(importLayout);
        importBuilder.setTitle("Import share");

        final EditText importCodeInput = (EditText) importLayout.findViewById(R.id.importCodeInput);
        final EditText importNameInput = (EditText) importLayout.findViewById(R.id.importNameInput);

        importBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                t = new Thread() {
                    public void run() {
                        Looper.prepare();
                        try {
                            mApi.addFromCopyRef(importCodeInput.getText().toString(),
                                    "/" + importNameInput.getText().toString());
                            mToastMessage = "Download the board from 'Download'";
                            mHandler.post(mShowToast);
                        } catch (DropboxException e) {
                            Log.e(TAG, "Unable to get shared board", e);
                        }
                    }
                };
                t.start();
            }
        });

        importBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
            }
        });
        importBuilder.show();
        return true;
    }

    return super.onMenuItemSelected(featureId, item);
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.list.TaskListFragment.java

private void shareSelected(Collection<Long> orgItemIds) {
    // This solves threading issues
    final long[] itemIds = ArrayHelper.toArray(orgItemIds);

    AsyncTaskHelper.background(new AsyncTaskHelper.Job() {
        @Override//from  w  ww  .  ja v a 2  s . co  m
        public void doInBackground() {
            final StringBuilder shareSubject = new StringBuilder();
            final StringBuilder shareText = new StringBuilder();

            final String whereId = new StringBuilder(Task.Columns._ID).append(" IN (")
                    .append(DAO.arrayToCommaString(itemIds)).append(")").toString();

            Cursor c = getContext().getContentResolver().query(Task.URI,
                    new String[] { Task.Columns._ID, Task.Columns.TITLE, Task.Columns.NOTE }, whereId, null,
                    null);

            if (c != null) {
                while (c.moveToNext()) {
                    if (shareText.length() > 0) {
                        shareText.append("\n\n");
                    }
                    if (shareSubject.length() > 0) {
                        shareSubject.append(", ");
                    }

                    shareSubject.append(c.getString(1));
                    shareText.append(c.getString(1));

                    if (!c.getString(2).isEmpty()) {
                        shareText.append("\n").append(c.getString(2));
                    }
                }

                c.close();
            }

            final Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_TEXT, shareText.toString());
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubject.toString());
            startActivity(shareIntent);
        }
    });
}