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:com.fvd.nimbus.BrowseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
    //overridePendingTransition(R.anim.carbon_slide_in,R.anim.carbon_slide_out);
    //overridePendingTransition(R.anim.activity_open_scale,R.anim.activity_close_translate);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    try {/*from   ww w  . j  a  va 2s .  c o  m*/
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    } catch (Exception e) {
        e.printStackTrace();
    }
    clipData = new DataExchange();
    isInitNow = true;
    setContentView(R.layout.screen_browser);
    serverHelper.getInstance().setCallback(this, this);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    lastUrl = prefs.getString("LAST_URL", "");
    saveCSS = prefs.getString("clipStyle", "1").equals("1");
    ctx = this;

    //adapter = new TextAdapter(this);      

    /*Uri data = getIntent().getData();
    if(data!=null){
       lastUrl=data.toString();
    }*/
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_VIEW.equals(action) /*&& type != null*/) {
        Uri data = intent.getData();
        if (data != null) {
            lastUrl = data.toString();
            appSettings.appendLog("browse:onCreate  " + lastUrl);
        }
    } else if (Intent.ACTION_SEND.equals(action) /*&& type != null*/) {
        if ("text/plain".equals(type)) {
            String surl = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (surl.contains(" ")) {
                String[] arr = surl.replace("\t", " ").split(" ");
                for (String s : arr) {
                    if (s.contains("://")) {
                        lastUrl = s.trim();
                        break;
                    }
                }
            } else if (surl.contains("://"))
                lastUrl = surl.trim();
            appSettings.appendLog("browse:onCreate  " + lastUrl);
        }
    }

    drawer = (DrawerLayout) findViewById(R.id.root);

    View v = findViewById(R.id.wv);
    wv = (fvdWebView) findViewById(R.id.wv);
    wv.setEventsHandler(this);
    //registerForContextMenu(wv); 
    urlField = (AutoCompleteTextView) findViewById(R.id.etAddess);
    urlField.setSelectAllOnFocus(true);
    urlField.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                /*InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);*/
                onNavButtonClicked();
                return true;
            } else if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                onNavButtonClicked();
                return true;
            }
            return false;
        }
    });
    onViewCreated();

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 0:
                findViewById(R.id.bZoomStack).setVisibility(View.VISIBLE);
                findViewById(R.id.bToggleMenu).setVisibility(View.GONE);

                break;

            default:
                break;
            }
        }
    };

    navButton = (ImageButton) findViewById(R.id.ibReloadWebPage);
    navButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //Toast.makeText(getApplicationContext(), "You made a mess", Toast.LENGTH_LONG).show();
            onNavButtonClicked();
        }
    });

    findViewById(R.id.bSavePageFragment).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //toggleTools();
            floatMenu.collapse();
            if (!wv.getInjected())
                Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show();
            clipMode = 2;
            if (wv.getInjected()/* && !v.isSelected()*/) {
                wv.setCanClip(true);
                v.setSelected(true);
                Toast.makeText(ctx, ctx.getString(R.string.use_longtap), Toast.LENGTH_LONG).show();
            }

        }
    });

    (findViewById(R.id.bSaveFullPage)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            floatMenu.collapse();
            if (wv.getInjected()) {
                wv.setCanClip(false);
                wv.saveArticle();
                clipMode = 1;
                progressDialog = ProgressDialog.show(v.getContext(), "Nimbus Clipper",
                        getString(R.string.please_wait), true, false);
            } else {
                Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show();
            }
        }
    });

    findViewById(R.id.bTakeScreenshot).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //toggleTools();
            floatMenu.collapse();
            findViewById(R.id.bSaveFullPage).setVisibility(View.GONE);
            findViewById(R.id.bSavePageFragment).setVisibility(View.GONE);
            findViewById(R.id.bTakeScreenshot).setVisibility(View.GONE);
            if (wv.getInjected()) {
                wv.setCanClip(false);
            }
            findViewById(R.id.bToggleMenu).setVisibility(View.GONE);
            /*screenCapture();
            findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE);*/

            findViewById(R.id.bTakeScreenshot).postDelayed(new Runnable() {
                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    screenCapture();
                    findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE);
                    finish();
                }
            }, 10);

            //showDialog(DIALOG_CAPTURE);
        }
    });

    (findViewById(R.id.bDone)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            {
                try {

                    wv.setCanClip(false);
                    wv.endSelectionMode();
                    //findViewById(R.id.bSavePageFragment).setSelected(false);
                    clipMode = 2;
                    wv.endSelectionMode();
                    String selHtml = clipData.getContent();
                    if (selHtml.length() > 0) {
                        String ss = selHtml.substring(0, selHtml.indexOf(">") + 1).toLowerCase();
                        int j = ss.indexOf("<div");
                        if (j == 0) {
                            j = ss.indexOf("style");
                            if (j > 0) {
                                int k = ss.indexOf("\"", j + 11);
                                if (k > 0)
                                    selHtml = selHtml.replace(selHtml.substring(j, k + 1), "");
                            }
                            //selHtml="<DIV>"+selHtml.substring(ss.length());
                        }
                        clipData.setContent(selHtml);
                        clipData.setTitle(wv.getTitle());

                        /*if (true){
                                    
                            if(sessionId.length() == 0 || userPass.length()==0) showSettings();
                            else {
                               if(prefs.getBoolean("check_fast", false)){
                         sendNote(wv.getTitle(), clipData.getContent(), parent, tag);
                         clipData.setContent("");
                               }
                               else {
                               //serverHelper.getInstance().setCallback(this,this);
                               if(appSettings.sessionId.length()>0) {
                         serverHelper.getInstance().sendRequest("notes:getFolders", "","");
                         }
                               }
                            }
                            wv.endSelectionMode();
                         } */

                        Intent i = new Intent(getApplicationContext(), previewActivity.class);
                        i.putExtra("content", clipData);
                        startActivityForResult(i, 5);
                        //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
                        overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
                    }
                    //clipData.setContent("");
                } catch (Exception e) {
                    BugReporter.Send("onEndSelection", e.getMessage());
                }
            }
            //showDialog(DIALOG_CAPTURE);
        }
    });

    findViewById(R.id.bZoomIn).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            wv.ZoomInSelection();
        }
    });

    findViewById(R.id.bZoomOut).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            wv.ZoomOutSelection();
        }
    });

    setNavButtonState(NavButtonState.NBS_GO);

    progressBar = (ProgressBar) findViewById(R.id.progressbar);

    //CookieSyncManager.createInstance(this);

    //webSettings.setLoadsImagesAutomatically(imgOn);
    userMail = prefs.getString("userMail", "");
    userPass = prefs.getString("userPass", "");
    sessionId = prefs.getString("sessionId", "");

    appSettings.sessionId = sessionId;
    appSettings.userMail = userMail;
    appSettings.userPass = userPass;

    if ("1".equals(prefs.getString("userAgent", "1"))) {
        wv.setUserAgent(null);
    } else
        wv.setUserAgent(deskAgent);

    final Activity activity = this;
    //lastUrl="file:///android_asset/android.html";
    if (lastUrl.length() > 0) {
        //wv.navigate(lastUrl);

        //if(!urlField.getText().toString().equals(wv.getUrl()))
        urlField.setText(lastUrl);
        openURL();
    }
    isInitNow = false;

    urlField.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            // TODO Auto-generated method stub
            /*String item = (String)parent.getItemAtPosition(position);
                    
            Toast.makeText(
                  getApplicationContext(),
                  "  "
                + item,
                  Toast.LENGTH_SHORT).show();*/
            openURL();

        }
    });

    urlField.addTextChangedListener(this);
    parent = prefs.getString("remFolderId", "default");

    /*ListView listView = (ListView) findViewById(R.id.left_drawer);
    listView.setAdapter(new DrawerMenuAdapter(this,getResources().getStringArray(R.array.lmenu_browser)));
    listView.setOnItemClickListener(this);*/
}

From source file:com.alley.android.ppi.app.DetailFragment.java

private Intent createSharePropertyIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mPropertyDescription + PROPERTY_PRICE_SHARE_HASHTAG);
    return shareIntent;
}

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

@Override
public void create() {
    try {//w w w.  jav 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:at.alladin.rmbt.android.about.RMBTAboutFragment.java

private View createView(View view, LayoutInflater inflater) {
    activity = getActivity();//  w w  w . j  a  v a 2  s.c  o m

    getAppInfo(activity);

    final String clientUUID = String.format("U%s", ConfigHelper.getUUID(activity.getApplicationContext()));

    final String controlServerVersion = ConfigHelper.getControlServerVersion(activity);

    final ListView listView = (ListView) view.findViewById(R.id.aboutList);

    final ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    HashMap<String, String> item;
    item = new HashMap<String, String>();
    item.put("title", clientName);
    item.put("text1", this.getString(R.string.about_rtr_line1));
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", this.getString(R.string.about_version_title));
    item.put("text1", clientVersion);
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_clientid_title));
    item.put("text1", clientUUID);
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_web_title));
    item.put("text1", getString(R.string.about_web_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_email_title));
    item.put("text1", getString(R.string.about_email_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_terms_title));
    item.put("text1", getString(R.string.about_terms_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_git_title));
    item.put("text1", getString(R.string.about_git_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_dev_title));
    item.put("text1", getString(R.string.about_dev_line1));
    item.put("text2", getString(R.string.about_dev_line2));
    list.add(item);

    final String openSourceSoftwareLicenseInfo = GooglePlayServicesUtil
            .getOpenSourceSoftwareLicenseInfo(getActivity());

    if (openSourceSoftwareLicenseInfo != null) {
        item = new HashMap<String, String>();
        item.put("title", getString(R.string.about_gms_legal_title));
        item.put("text1", getString(R.string.about_gms_legal_line1));
        item.put("text2", "");
        list.add(item);
    }

    if (ConfigHelper.isDevEnabled(getActivity())) {
        item = new HashMap<String, String>();
        item.put("title", getString(R.string.about_test_counter_title));
        item.put("text1", Integer.toString(ConfigHelper.getTestCounter(getActivity())));
        item.put("text2", "");
        list.add(item);
    }

    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_control_server_version));
    item.put("text1", controlServerVersion != null ? controlServerVersion : "---");
    item.put("text2", "");
    list.add(item);

    sa = new RMBTAboutAdapter(getActivity(), list, R.layout.about_item,
            new String[] { "title", "text1", "text2" }, new int[] { R.id.title, R.id.text1, R.id.text2 });

    listView.setAdapter(sa);

    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> l, final View v, final int position, final long id) {

            switch (position) {

            case 1:
                handleHiddenCode();
                break;

            case 2:
                final android.content.ClipboardManager clipBoard = (android.content.ClipboardManager) getActivity()
                        .getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("client_uuid", clientUUID);
                clipBoard.setPrimaryClip(clip);
                final Toast toast = Toast.makeText(getActivity(), R.string.about_clientid_toast,
                        Toast.LENGTH_LONG);
                toast.show();
                break;

            case 3:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_web_link))));
                break;

            case 4:
                /* Create the Intent */
                final Intent emailIntent = new Intent(Intent.ACTION_SEND);

                /* Fill it with Data */
                emailIntent.setType("plain/text");
                emailIntent.putExtra(Intent.EXTRA_EMAIL,
                        new String[] { getString(R.string.about_email_email) });
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.about_email_subject));
                emailIntent.putExtra(Intent.EXTRA_TEXT, "");

                /* Send it off to the Activity-Chooser */
                startActivity(Intent.createChooser(emailIntent, getString(R.string.about_email_sending)));

                break;

            case 5:
                final FragmentManager fm = activity.getSupportFragmentManager();
                FragmentTransaction ft;
                ft = fm.beginTransaction();
                ft.replace(R.id.fragment_content, new RMBTTermsFragment(), "terms");
                ft.addToBackStack("terms");
                ft.commit();
                break;

            case 6:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_git_link))));
                break;

            case 7:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_dev_link))));
                break;

            case 8:
                final String licenseInfo = GooglePlayServicesUtil
                        .getOpenSourceSoftwareLicenseInfo(getActivity());
                AlertDialog.Builder licenseDialog = new AlertDialog.Builder(getActivity());
                licenseDialog.setMessage(licenseInfo);
                licenseDialog.show();
                break;

            default:
                break;
            }
        }

    });

    return view;
}

From source file:com.albedinsky.android.support.intent.ShareIntent.java

/**
 *///from   ww w  .j a v a2 s  .  c om
@NonNull
@Override
protected Intent onBuild() {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(mDataType);
    if (!TextUtils.isEmpty(mTitle)) {
        intent.putExtra(Intent.EXTRA_TITLE, mTitle);
    }
    if (!TextUtils.isEmpty(mContent)) {
        intent.putExtra(Intent.EXTRA_TEXT, mContent);
    }
    if (mUri != null) {
        intent.putExtra(Intent.EXTRA_STREAM, mUri);
    } else if (mUris != null) {
        intent.setAction(Intent.ACTION_SEND_MULTIPLE);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(mUris));
    }
    return intent;
}

From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java

public boolean checkStackTrace() {
    FileInputStream traceIn = null;
    try {//from  w  w w .j a  v  a  2  s  .com
        traceIn = openFileInput("stack.trace");
        traceIn.close();
    } catch (FileNotFoundException fnfe) {
        // No stack trace available
        return false;
    } catch (IOException ioe) {
        return false;
    }

    AlertDialog alert = new AlertDialog.Builder(this).create();
    alert.setMessage(getResources().getString(R.string.crashreport_msg));

    alert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.emailstr),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    String trace = "";
                    String line = null;
                    try {
                        BufferedReader reader = new BufferedReader(
                                new InputStreamReader(TwitSpeakActivity.this.openFileInput("stack.trace")));
                        while ((line = reader.readLine()) != null) {
                            trace += line + "\n";
                        }
                    } catch (FileNotFoundException fnfe) {
                        Log.logException(TAG, fnfe);
                    } catch (IOException ioe) {
                        Log.logException(TAG, ioe);
                    }

                    Intent sendIntent = new Intent(Intent.ACTION_SEND);
                    String subject = "Error report";
                    String body = getResources().getString(R.string.mailthisto_msg) + " jayesh@altcanvas.com: "
                            + "\n\n" + G.getPhoneInfo() + "\n\n" + "TwitSpeak [" + G.VERSION_STRING + "]"
                            + "\n\n" + trace + "\n\n";

                    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jayesh@altcanvas.com" });
                    sendIntent.putExtra(Intent.EXTRA_TEXT, body);
                    sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
                    sendIntent.setType("message/rfc822");

                    TwitSpeakActivity.this.startActivityForResult(
                            Intent.createChooser(sendIntent, getResources().getString(R.string.emailstr)),
                            G.REQCODE_EMAIL_STACK_TRACE);

                    TwitSpeakActivity.this.deleteFile("stack.trace");
                }
            });
    alert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancelstr),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    TwitSpeakActivity.this.deleteFile("stack.trace");
                    TwitSpeakActivity.this.continueOnCreate();
                }
            });

    alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            TwitSpeakActivity.this.deleteFile("stack.trace");
            TwitSpeakActivity.this.continueOnCreate();
        }
    });

    alert.show();

    return true;
}

From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    if (ACTION_DIALOG.equals(intent.getAction())) {
        showDialog(intent.getStringExtra(Intent.EXTRA_TEXT));
    }
}

From source file:com.zia.freshdocs.widget.adapter.CMISAdapter.java

/**
 * Send the content using a built-in Android activity which can handle the
 * content type.//ww w  . ja v a  2 s .  c om
 * 
 * @param position
 */
public void shareContent(int position) {
    final NodeRef ref = getItem(position);
    downloadContent(ref, new Handler() {
        public void handleMessage(Message msg) {
            Context context = getContext();
            boolean done = msg.getData().getBoolean("done");

            if (done) {
                dismissProgressDlg();

                File file = (File) mDlThread.getResult();

                if (file != null) {
                    Resources res = context.getResources();
                    Uri uri = Uri.fromFile(file);
                    Intent emailIntent = new Intent(Intent.ACTION_SEND);
                    emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, ref.getName());
                    emailIntent.putExtra(Intent.EXTRA_TEXT, res.getString(R.string.email_text));
                    emailIntent.setType(ref.getContentType());

                    try {
                        context.startActivity(
                                Intent.createChooser(emailIntent, res.getString(R.string.email_title)));
                    } catch (ActivityNotFoundException e) {
                        String text = "No suitable applications registered to send " + ref.getContentType();
                        int duration = Toast.LENGTH_SHORT;
                        Toast toast = Toast.makeText(context, text, duration);
                        toast.show();
                    }
                }
            } else {
                int value = msg.getData().getInt("progress");
                if (value > 0) {
                    mProgressDlg.setProgress(value);
                }
            }
        }
    });
}

From source file:com.achep.base.ui.fragments.dialogs.FeedbackDialog.java

private void send(@NonNull CharSequence title, @NonNull CharSequence body, boolean attachLog) {
    Activity context = getActivity();/*  www . j a va2s . c  o  m*/
    String[] recipients = { Build.SUPPORT_EMAIL };
    Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients).putExtra(Intent.EXTRA_SUBJECT, title)
            .putExtra(Intent.EXTRA_TEXT, body);

    if (attachLog) {
        attachLog(intent);
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("message/rfc822");
    } else {
        intent.setAction(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:")); // only email apps should handle it
    }

    if (IntentUtils.hasActivityForThat(context, intent)) {
        startActivity(intent);
        dismiss();
    } else {
        ToastUtils.showLong(context, R.string.feedback_error_no_app);
    }
}

From source file:ca.rmen.android.poetassistant.main.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    Log.d(TAG, "onNewIntent() called with: " + "intent = [" + intent + "]");
    setIntent(intent);/*w w  w  .  j  a va 2 s .  c o m*/
    // The user entered a search term either by typing or by voice
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getDataString();
        if (TextUtils.isEmpty(query)) {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if (TextUtils.isEmpty(query)) {
            CharSequence userQuery = intent.getCharSequenceExtra(SearchManager.USER_QUERY);
            if (!TextUtils.isEmpty(userQuery))
                query = userQuery.toString();
        }
        if (TextUtils.isEmpty(query))
            return;
        mSearch.addSuggestions(query);
        mSearch.search(query);
    }
    // We got here from a deep link
    else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri data = getIntent().getData();
        handleDeepLink(data);
    }
    // Play some text in the tts tab
    else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        mBinding.viewPager.setCurrentItem(mPagerAdapter.getPositionForTab(Tab.READER));
        String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
        ReaderFragment readerFragment = (ReaderFragment) mPagerAdapter.getFragment(mBinding.viewPager,
                Tab.READER);
        readerFragment.setText(sharedText);
    }
}