当前位置: 首页>>代码示例>>Java>>正文


Java Intent.setType方法代码示例

本文整理汇总了Java中android.content.Intent.setType方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.setType方法的具体用法?Java Intent.setType怎么用?Java Intent.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.setType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: share

import android.content.Intent; //导入方法依赖的package包/类
public static void share(AppCompatActivity context, List<String> paths) {

        if (paths == null || paths.size() == 0) {
            return;
        }
        ArrayList<Uri> uris = new ArrayList<>();
        Intent intent = new Intent();
        intent.setAction(android.content.Intent.ACTION_SEND_MULTIPLE);
        intent.setType("*/*");
        for (String path : paths) {
            File file = new File(path);
            uris.add(Uri.fromFile(file));
        }
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        context.startActivity(intent);
    }
 
开发者ID:LightSun,项目名称:android-util2,代码行数:17,代码来源:IntentHelper.java

示例2: onContextItemSelected

import android.content.Intent; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case TAKE_PHOTO:
            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File f = new File(Environment.getExternalStorageDirectory() + TMP_METACOM_JPG);
            Uri uri = FileProvider.getUriForFile(getContext(), AUTHORITY_STRING, f);
            takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);
            takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
                startActivityForResult(takePictureIntent, PICK_IMAGE_FROM_CAMERA);
            }
            return true;
        case FILE_EXPLORER:
            Intent intent = new Intent();
            intent.setType("*/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, getString(R.string
                            .select_file)),
                    PICK_IMAGE_FROM_EXPLORER);
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
 
开发者ID:metarhia,项目名称:metacom-android,代码行数:26,代码来源:ChatFragment.java

示例3: onShareClick

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onShareClick(String sourceUrl) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, sourceUrl);
    sendIntent.setType("text/plain");
    startActivity(Intent.createChooser(sendIntent, "Share using..."));
}
 
开发者ID:vicky7230,项目名称:Paprika,代码行数:9,代码来源:RecipesFragment.java

示例4: onScanCompleted

import android.content.Intent; //导入方法依赖的package包/类
@Override
                public void onScanCompleted(String path, Uri uri) {
                    if (DEBUG) Log.v(TAG, "File scanned: " + path);
                    synchronized (mDrawingsToScan) {
                        if (path.equals(mPendingShareFile)) {
                            Intent sendIntent = new Intent(Intent.ACTION_SEND);
                            sendIntent.setType("image/png");
                            sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
                            startActivity(Intent.createChooser(sendIntent, "Send drawing to:"));
                            mPendingShareFile = null;
                        }
                        scanNext();
                    }


//                    if (saved) {
                        saved = false ;
                        Intent returnIntent = getIntent();
                        returnIntent.putExtra("path", path);
                        setResult(RESULT_OK, returnIntent);
                        finish();
//                    }


                }
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:26,代码来源:MarkersActivity.java

示例5: sendSMS

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Send an SMS message using the default application.
 */
private void sendSMS() {
	try {
		Log.d(TAG, this.getClass().getSimpleName()
				+ ": sendSMS: mLatitude=" + mLatitude + " mLongitude="
				+ mLongitude);
		// Create the message
		int[] vals = getTowerValues();
		Date now = new Date();
		String msg = now + "\n";
		msg += "NID=" + mNid + " SID=" + mSid + " BID=" + mBid + "\n"
				+ String.format("%.6f", mLatitude * 1.e-6) + ","
				+ String.format("%.6f", mLongitude * 1.e-6);
		if (vals == null) {
			Utils.errMsg(this, "Cannot get tower values");
			return;
		}

		// Start the default SMS activity
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.putExtra("sms_body", msg);
		intent.setType("vnd.android-dir/mms-sms");
		startActivity(intent);
	} catch (Exception ex) {
		Utils.excMsg(this, "Error sending SMS", ex);
	}
}
 
开发者ID:KennethEvans,项目名称:Misc,代码行数:30,代码来源:MapLocationActivity.java

示例6: sending

import android.content.Intent; //导入方法依赖的package包/类
public void sending() {
    Log.d(TAG, "Sending");

    if (!validate()) {
        onSendFailed();
        return;
    }

    _sendButton.setEnabled(false);

    final ProgressDialog progressDialog = new ProgressDialog(SendMail.this,
            R.style.AppTheme_Dark_Dialog);
    progressDialog.setIndeterminate(true);
    progressDialog.setMessage("И-мэйл илгээж байна...");
    progressDialog.show();

    String from = _fromText.getText().toString();
    String to = _toText.getText().toString();
    String subject = _subjectText.getText().toString();
    String composeEmail = _composeEmailText.getText().toString();
    Intent sendingMailIntent = new Intent(Intent.ACTION_SEND);
    sendingMailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
    sendingMailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    sendingMailIntent.putExtra(Intent.EXTRA_TEXT,composeEmail);
    sendingMailIntent.setType("message/rfc822");
    startActivity(sendingMailIntent);

    new android.os.Handler().postDelayed(
            new Runnable() {
                public void run() {
                    // On complete call either onSignupSuccess or onSignupFailed
                    // depending on success
                    onSendSuccess();
                    // onSignupFailed();
                    progressDialog.dismiss();
                }
            }, 3000);
}
 
开发者ID:tortuvshin,项目名称:actions,代码行数:39,代码来源:SendMail.java

示例7: createChooser

import android.content.Intent; //导入方法依赖的package包/类
private void createChooser() {
    if(ContextCompat.checkSelfPermission(UploadNewsFeedActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)== PackageManager.PERMISSION_DENIED){

        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
            requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 121);
        }

        return;

    }

    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(Intent.createChooser(intent, "CHOOSE PHOTO"), PICK_IMAGE_REQUEST);
}
 
开发者ID:appteam-nith,项目名称:Nimbus,代码行数:16,代码来源:UploadNewsFeedActivity.java

示例8: share

import android.content.Intent; //导入方法依赖的package包/类
public static void share(Context context, String extraText) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.action_share));
    intent.putExtra(Intent.EXTRA_TEXT, extraText);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(
            Intent.createChooser(intent, context.getString(R.string.action_share)));
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:10,代码来源:ShareUtil.java

示例9: showSystemShareOption

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 调用系统安装了的应用分享
 *
 * @param context
 * @param title
 * @param url
 */
public static void showSystemShareOption(Activity context,
                                         final String title, final String url) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享:" + title);
    intent.putExtra(Intent.EXTRA_TEXT, title + " " + url);
    context.startActivity(Intent.createChooser(intent, "选择分享"));
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:16,代码来源:DeviceUtils.java

示例10: shareTwitter

import android.content.Intent; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void shareTwitter() {
    Intent twitterIntent = new Intent();
    twitterIntent.setType("text/plain");
    twitterIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.like_text));

    final PackageManager packageManager = getActivity().getPackageManager();
    List<ResolveInfo> list = packageManager.queryIntentActivities(twitterIntent, PackageManager.MATCH_DEFAULT_ONLY);

    boolean found = false;
    for (ResolveInfo resolveInfo : list) {
        String p = resolveInfo.activityInfo.packageName;
        if (p != null && p.startsWith("com.twitter.android")) {
            found = true;
            twitterIntent.setPackage(p);
            startActivity(twitterIntent);

            ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                    .send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("Twitter").setLabel("App").build());
        }
    }

    if (!found) {
        ProgressDialog progressDialog = new ProgressDialog(getActivity());

        TwitterShare d = new TwitterShare(
                getActivity(), progressDialog,
                "http://twitter.com/share?text=" + Uri.encode(getString(R.string.like_text_twitter)) + "&url=" + Uri.parse(getString(R.string.like_url)));
        d.show();

        progressDialog.setMessage(getString(R.string.text_loading));
        progressDialog.setCancelable(true);
        progressDialog.show();

        ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                .send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("Twitter").setLabel("Web").build());
    }
}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:39,代码来源:NavigationDrawerFragment.java

示例11: choseHeadImageFromGallery

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 从手机相册选择图片设置用户头像
 */
private void choseHeadImageFromGallery() {
    Intent intentFromGallery = new Intent();
    //设置文件类型
    intentFromGallery.setType("image/*");
    intentFromGallery.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(intentFromGallery,CODE_GALLERY_REQUEST);
}
 
开发者ID:AndroidBoySC,项目名称:Mybilibili,代码行数:11,代码来源:MainActivity.java

示例12: ShareText

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 分享文字至所有第三方软件
 *
 * @param context
 * @param content
 */
public static void ShareText(Context context, String content) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, content);
    intent.setType("text/plain");
    //设置分享列表的标题,并且每次都显示分享列表
    context.startActivity(Intent.createChooser(intent, "分享到"));

}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:16,代码来源:LocalShareUtils.java

示例13: openFileChooser

import android.content.Intent; //导入方法依赖的package包/类
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
    BrowserActivity.this.mUploadMessage = uploadMsg;
    Intent i = new Intent("android.intent.action.GET_CONTENT");
    i.addCategory("android.intent.category.OPENABLE");
    i.setType("*/*");
    BrowserActivity.this.startActivityForResult(Intent.createChooser(i, "File Browser"), 1);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:BrowserActivity.java

示例14: isUseClientToShare

import android.content.Intent; //导入方法依赖的package包/类
/** 判断指定平台是否只能使用客户端分享 */
final boolean isUseClientToShare(Platform platform) {
	String name = platform.getName();
	if ("Wechat".equals(name) || "WechatMoments".equals(name)
			|| "WechatFavorite".equals(name) || "ShortMessage".equals(name)
			|| "Email".equals(name) || "GooglePlus".equals(name)
			|| "QQ".equals(name) || "Pinterest".equals(name)
			|| "Instagram".equals(name) || "Yixin".equals(name)
			|| "YixinMoments".equals(name) || "QZone".equals(name)
			|| "Mingdao".equals(name) || "Line".equals(name)
			|| "KakaoStory".equals(name) || "KakaoTalk".equals(name)
			|| "Bluetooth".equals(name) || "WhatsApp".equals(name)
			|| "BaiduTieba".equals(name) || "Laiwang".equals(name)
			|| "LaiwangMoments".equals(name) || "Alipay".equals(name)
			|| "FacebookMessenger".equals(name)
			) {
		return true;
	} else if ("Evernote".equals(name)) {
		if ("true".equals(platform.getDevinfo("ShareByAppClient"))) {
			return true;
		}
	} else if ("SinaWeibo".equals(name)) {
		if ("true".equals(platform.getDevinfo("ShareByAppClient"))) {
			Intent test = new Intent(Intent.ACTION_SEND);
			test.setPackage("com.sina.weibo");
			test.setType("image/*");
			ResolveInfo ri = platform.getContext().getPackageManager().resolveActivity(test, 0);
			return (ri != null);
		}
	}

	return false;
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:34,代码来源:OnekeyShareThemeImpl.java

示例15: gotoPhoto

import android.content.Intent; //导入方法依赖的package包/类
/**
 * open camera (need permission)
 */
void gotoPhoto() {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_CODE_PHOTO);
}
 
开发者ID:ChangsenLai,项目名称:codedemos,代码行数:10,代码来源:CameraUtilActivity.java


注:本文中的android.content.Intent.setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。