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


Java Intent.createChooser方法代码示例

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


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

示例1: activeShare

import android.content.Intent; //导入方法依赖的package包/类
public static void activeShare(Activity activity, Intent sendIntent, String pkg, String targetActivity) throws Exception {
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (!TextUtils.isEmpty(targetActivity))
        sendIntent.setClassName(pkg, targetActivity);
    try {
        Intent chooserIntent = Intent.createChooser(sendIntent, "请选择");
        if (chooserIntent == null) {
            return;
        }

        activity.startActivityForResult(chooserIntent, SHARE_REQ_CODE);
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}
 
开发者ID:chendongMarch,项目名称:SocialSdkLibrary,代码行数:18,代码来源:IntentShareUtils.java

示例2: shareText

import android.content.Intent; //导入方法依赖的package包/类
private void shareText(String text) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    sendIntent.setType("*/*");
    try {
        Intent chooserIntent = Intent.createChooser(sendIntent, "选择分享途径");
        if (chooserIntent == null) {
            return;
        }
        startActivity(chooserIntent);
    } catch (Exception e) {
        startActivity(sendIntent);
    }
}
 
开发者ID:w568w,项目名称:fuckView,代码行数:16,代码来源:PreferencesActivity.java

示例3: share

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 分享内容
 */
@OnClick(R.id.shareBtn)
void share() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_TEXT, mResultEt.getText().toString());
    Intent chooserIntent = Intent.createChooser(intent, getString(R.string.string_choise_intent));
    if (chooserIntent == null) {
        return;
    }
    try {
        startActivity(chooserIntent);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(this, R.string.string_share_error, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:shenhuanet,项目名称:Ocr-android,代码行数:20,代码来源:ResultActivity.java

示例4: onClickShare

import android.content.Intent; //导入方法依赖的package包/类
@OnClick(R.id.fab_share)
public void onClickShare() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "NFKita");
    shareIntent.putExtra(Intent.EXTRA_TEXT, getIntent("url"));
    Intent new_intent = Intent.createChooser(shareIntent, "Share it");
    new_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(new_intent);
}
 
开发者ID:daeng-id,项目名称:nfkita-mobile,代码行数:12,代码来源:ReadArticleActivity.java

示例5: changeAvatar

import android.content.Intent; //导入方法依赖的package包/类
private void changeAvatar() {
    List<Intent> otherImageCaptureIntent = new ArrayList<>();
    List<ResolveInfo> otherImageCaptureActivities =
            getPackageManager().queryIntentActivities(new Intent(MediaStore.ACTION_IMAGE_CAPTURE),
                    0); // finding all intents in apps which can handle capture image
    // loop through all these intents and for each of these activities we need to store an intent
    for (ResolveInfo info : otherImageCaptureActivities) { // Resolve info represents an activity on the system that does our work
        Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        captureIntent.setClassName(info.activityInfo.packageName,
                info.activityInfo.name); // declaring explicitly the class where we will go
        // where the picture activity dump the image
        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempOutputFile));
        otherImageCaptureIntent.add(captureIntent);
    }

    // above code is only for taking picture and letting it go through another app for cropping before setting to imageview
    // now below is for choosing the image from device

    Intent selectImageIntent = new Intent(Intent.ACTION_PICK);
    selectImageIntent.setType("image/*");

    Intent chooser = Intent.createChooser(selectImageIntent, "Choose Avatar");
    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, otherImageCaptureIntent.toArray(
            new Parcelable[otherImageCaptureActivities.size()]));  // add 2nd para as intent of parcelables.

    startActivityForResult(chooser, REQUEST_SELECT_IMAGE);
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:28,代码来源:CreateGroupDescActivity.java

示例6: onClick

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
	final int id = v.getId();
	if(id==R.id.capture_scan_photo){
		// 打开手机中的相册
		Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); // "android.intent.action.GET_CONTENT"
		innerIntent.setType("image/*");
		Intent wrapperIntent = Intent.createChooser(innerIntent,
				"选择二维码图片");
		this.startActivityForResult(wrapperIntent, REQUEST_CODE);
	}else if(id==R.id.capture_flashlight){
		if (isFlashlightOpen) {
			cameraManager.setTorch(false); // 关闭闪光灯
			isFlashlightOpen = false;
		}
		else {
			cameraManager.setTorch(true); // 打开闪光灯
			isFlashlightOpen = true;
		}
	}
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:22,代码来源:CaptureActivity.java

示例7: openEmailApp

import android.content.Intent; //导入方法依赖的package包/类
private void openEmailApp() {
    Intent intent = new Intent(Intent.ACTION_SEND, Uri.fromParts(
            "mailto",email, null));
    intent.setType("message/rfc822");
    intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {email});
    Intent mailer = Intent.createChooser(intent, null);
    context.startActivity(mailer);
}
 
开发者ID:Lars3n95,项目名称:AppRater-Dialog,代码行数:9,代码来源:AppRaterDialog.java

示例8: createEmailOnlyChooserIntent

import android.content.Intent; //导入方法依赖的package包/类
public static Intent createEmailOnlyChooserIntent(Context context, Intent source,
                                                  CharSequence chooserTitle) {
    Stack<Intent> intents = new Stack<>();
    Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
            "[email protected]", null));
    List<ResolveInfo> activities = context.getPackageManager()
            .queryIntentActivities(i, 0);

    for (ResolveInfo ri : activities) {
        Intent target = new Intent(source);
        target.setPackage(ri.activityInfo.packageName);
        intents.add(target);
    }

    if (!intents.isEmpty()) {
        Intent chooserIntent = Intent.createChooser(intents.remove(0),
                chooserTitle);
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                intents.toArray(new Parcelable[intents.size()]));

        return chooserIntent;
    } else {
        return Intent.createChooser(source, chooserTitle);
    }
}
 
开发者ID:HitRoxxx,项目名称:FloatingNew,代码行数:26,代码来源:Utils.java

示例9: startActivity

import android.content.Intent; //导入方法依赖的package包/类
private static void startActivity(String action,String filename,Context ctx){
    Uri uri=FileUtils.getUri(filename);
    Intent intent=new Intent();
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.setAction(action);
    intent.setDataAndType(uri,FileUtils.getMimeType(filename));
    Intent chooser;
    if(action.equals(Intent.ACTION_SEND)){
        chooser=Intent.createChooser(intent,"Sharing....");
        if(intent.resolveActivity(ctx.getPackageManager())!=null) {
            ctx.startActivity(chooser);
        }
    }else{
        chooser=Intent.createChooser(intent,"Open with....");
        if(intent.resolveActivity(ctx.getPackageManager())!=null){
            ctx.startActivity(chooser);
        }else{
            openWith(filename,ctx);
        }
    }
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:22,代码来源:UiUtils.java

示例10: onClick

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    switch(view.getId()){
        case R.id.activity_rant_user_into_rl_clickable:
            Intent intent1 = ProfileActivity.newIntent(RantActivity.this, mDetailItem.getUserId());
            startActivity(intent1);
            break;
        case R.id.activity_rant_btn_submit:
            Intent intent = CommentActivity.newIntent(this, rantId);
            startActivity(intent);
            break;
        case R.id.activity_rant_share_wechat:
            shareToWX(0);
            break;
        case R.id.activity_rant_share_quan:
            shareToWX(1);
            break;
        case R.id.activity_rant_share:
            String text = mDetailItem.getUserName()+"说: "+mDetailItem.getRantContent()+" " + "\n目前有"+mDetailItem.getCommentList().size()+"人围观,来凑个热闹吧!地址 "+getString(R.string.ip_server)+"rant.action?rantId="+mDetailItem.getRantId();
            Intent i=new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_TEXT,text);
            String server = getResources().getString(R.string.ip_server);
            i.putExtra(Intent.EXTRA_SUBJECT,server+"rant/rant.action?rantId="+mDetailItem.getRantId());
            i=Intent.createChooser(i,getString(R.string.rant_send_report));
            startActivity(i);
            break;

    }
}
 
开发者ID:shawnsky,项目名称:RantApp,代码行数:31,代码来源:RantActivity.java

示例11: getPickImageIntent

import android.content.Intent; //导入方法依赖的package包/类
public static Intent getPickImageIntent(final Context context) {
    final Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);

    return Intent.createChooser(intent, "Select picture");
}
 
开发者ID:marco97pa,项目名称:punti-burraco,代码行数:8,代码来源:MediaStoreUtils.java

示例12: deviceInf

import android.content.Intent; //导入方法依赖的package包/类
public static void deviceInf(Context ctx) {

        String deviceInfo = "Device Info:";
        deviceInfo += "\n Android Version: " + Build.VERSION.RELEASE;
        deviceInfo += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT;
        deviceInfo += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")";
        deviceInfo += "\n Device: " + android.os.Build.DEVICE;

        deviceInfo += "\n Model (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";
        deviceInfo += "\n Model manufacturer:" + Build.BRAND;
        deviceInfo += "\n Model Hardware:" +Build.HARDWARE;

        PackageInfo pinfo = null;
        try {
            pinfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e1) {
            e1.printStackTrace();
        }

        int versionNumber = pinfo.versionCode;
        String versionName = pinfo.versionName;

        deviceInfo +="\n App Version : " + versionName + versionNumber;
        deviceInfo += "\n Root Status:" +isRooted();

        String locale = ctx.getResources().getConfiguration().locale.getCountry();
        deviceInfo += "\n Country:" + locale;

        Intent email = new Intent(Intent.ACTION_SEND);

        String emailID = emailaddress();
        email.putExtra(Intent.EXTRA_EMAIL, new String[]{emailID});
        email.putExtra(Intent.EXTRA_SUBJECT, ctx.getPackageName() + " Feedback /Bug Report");
        email.setType("message/rfc822");
        email.putExtra(Intent.EXTRA_TEXT, "\n\n\n" + deviceInfo);
        Intent new_intent = Intent.createChooser(email, "Email Via...");
        new_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        ctx.startActivity(new_intent);

    }
 
开发者ID:kanishqgupta,项目名称:FeedbackerLib,代码行数:41,代码来源:feedbacker.java

示例13: openURL

import android.content.Intent; //导入方法依赖的package包/类
/**
 * @Description: Abrir uma URL passada
 * @param context: Context da Intent
 * @param url: URL para abrir
 */
public static void openURL(Context context, String url)
{
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    try {
        Intent chooser = Intent.createChooser(intent, TEXTO_CONTINUAR_COM);
        context.startActivity(chooser);
    } catch (ActivityNotFoundException ex) {
        Toast.makeText(context, "Error: Não foi possível abrir a URL", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:MarioDeAraujoCarvalho,项目名称:FlyHttp,代码行数:17,代码来源:InternetUtil.java

示例14: testSendLogsSingle

import android.content.Intent; //导入方法依赖的package包/类
@Test
    public void testSendLogsSingle() {
        Activity activity = mock(Activity.class);
        Context context = mock(Context.class);
        File file = mock(File.class);
        MockContentResolver resolver = new MockContentResolver();

        when(file.getPath()).thenReturn("/com/mindera/skeletoid");

        when(activity.getFilesDir()).thenReturn(file);
        when(activity.getPackageName()).thenReturn("com.mindera.skeletoid");
        when(activity.getApplicationContext()).thenReturn(context);
        when(activity.getContentResolver()).thenReturn(resolver);
        when(context.getFilesDir()).thenReturn(file);

        Uri uri = mock(Uri.class);

        mockStatic(FileProvider.class);
        when(FileProvider.getUriForFile(any(Activity.class), any(String.class), any(File.class))).thenReturn(uri);

        mockStatic(Intent.class);
        ArgumentCaptor<Intent> intentArgument = ArgumentCaptor.forClass(Intent.class);
        ArgumentCaptor<String> titleArgument = ArgumentCaptor.forClass(String.class);

        ShareLogFilesUtils.sendLogs(activity, "intentChooserTitle", "subjectTitle", "bodyText", new String[0], file);

        verifyStatic();
        Intent.createChooser(intentArgument.capture(), titleArgument.capture());

        assertNotNull(intentArgument.getValue());
//        assertEquals(Intent.ACTION_SEND, intentArgument.getValue().getAction());

        assertNotNull(titleArgument.getValue());
//        assertEquals("intentChooserTitle", titleArgument.getValue());
    }
 
开发者ID:Mindera,项目名称:skeletoid,代码行数:36,代码来源:ShareLogFilesUtilsUnitTests.java

示例15: shareDefault

import android.content.Intent; //导入方法依赖的package包/类
public void shareDefault(@NonNull Activity activity, Intent shareIntent, String dialogTitle) {
    //创建分享的Dialog
    try {
        shareIntent = Intent.createChooser(shareIntent, dialogTitle);
        activity.startActivity(shareIntent);
    } catch (Exception e) {
        // error
        // sometime , there is no app to share
        Toast.makeText(activity, "分享失败", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:12,代码来源:AndroidShareHelper.java


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