- private boolean handleSendIntent(Intent intent) {
- Bundle extras = intent.getExtras();
- if (extras == null) {
- return false;
- }
- final String mimeType = intent.getType();
- String action = intent.getAction();
- if (Intent.ACTION_SEND.equals(action)) {
- if (extras.containsKey(Intent.EXTRA_STREAM)) {
- Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
- boolean wildcard = "*/*".equals(mimeType);
- if (mimeType.startsWith("image/") || (wildcard && uri.toString().startsWith(mImageUri))) {
- setAttachment(1,uri, true);
- } else if (mimeType.startsWith("video/") || (wildcard && uri.toString().startsWith(mVideoUri))) {
- setAttachment(2,uri, true);
- }
- //addAttachment(mimeType, uri, false);
- return true;
- } else if (extras.containsKey(Intent.EXTRA_TEXT)) {
- MessageText.setText(extras.getString(Intent.EXTRA_TEXT));
- return true;
- }
- Toast.makeText(this, getString(R.string.message_too_big_for_video), Toast.LENGTH_SHORT).show();
- }
- //该片段来自于http://www.codesnippet.cn/detail/200520133445.html
来源: http://www.codesnippet.cn/detail/200520133445.html