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


Java Intent.resolveActivity方法代码示例

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


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

示例1: onListItemClick

import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Location loc = (Location) l.getAdapter().getItem(position);
    Toast.makeText(this, loc.getLatitude() + " " + loc.getLongitude(), Toast.LENGTH_SHORT).show();

    //simplesmente centraliza o mapa na latitude/longitude escolhida
    //nao amarra com google maps
    String locData = "geo:"+loc.getLatitude()+","+loc.getLongitude();

    //locData = "geo:"+loc.getLatitude()+","+loc.getLongitude()+"(AQUI)";

    //abre streetview
    //locData = "google.streetview:cbll="+loc.getLatitude()+","+loc.getLongitude();

    //abre navigation
    //locData = "google.navigation:q="+loc.getLatitude()+","+loc.getLongitude();

    Uri locationURI = Uri.parse(locData);

    Intent i = new Intent(Intent.ACTION_VIEW, locationURI);
    if (i.resolveActivity(getPackageManager()) != null) {
        startActivity(i);
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:25,代码来源:LocationActivity.java

示例2: onOptionsItemSelected

import android.content.Intent; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_refresh) {
        refresh();
        return true;
    } else if (id == R.id.action_copy_url) {
        ClipBoards.copyToClipBoard(this, webView.getUrl());
        makeText(this, R.string.web_tip_copy_done, Toast.LENGTH_SHORT).show();
        return true;
    } else if (id == R.id.action_open_url) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            makeText(this, R.string.web_tip_open_fail, Toast.LENGTH_LONG).show();
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:drakeet,项目名称:rebase-android,代码行数:22,代码来源:WebActivity.java

示例3: sendFeedbackSharingIntent

import android.content.Intent; //导入方法依赖的package包/类
private void sendFeedbackSharingIntent(){
    Intent shareIntent= ShareCompat.IntentBuilder.from(this)
            .setType("text/plain")
            //.setType("application/txt") with this flag filters much better, but not as good as sendFeedBabck
            .addEmailTo(getString(R.string.mailto))
            .setSubject(getString(R.string.subject))
            .setText(Constants.EMPTY_STRING)
            .setChooserTitle(R.string.sendchooser_text)
            .createChooserIntent()
            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    if (shareIntent.resolveActivity(getPackageManager()) != null) {
        startActivity(shareIntent);
    }
}
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:17,代码来源:MainActivity.java

示例4: openPreferredLocationInMap

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Uses the URI scheme for showing a location found on a map in conjunction with
 * an implicit Intent. This super-handy Intent is detailed in the "Common Intents" page of
 * Android's developer site:
 *
 * @see "http://developer.android.com/guide/components/intents-common.html#Maps"
 * <p>
 * Protip: Hold Command on Mac or Control on Windows and click that link to automagically
 * open the Common Intents page
 */
private void openPreferredLocationInMap() {
    double[] coords = SunshinePreferences.getLocationCoordinates(this);
    String posLat = Double.toString(coords[0]);
    String posLong = Double.toString(coords[1]);
    Uri geoLocation = Uri.parse("geo:" + posLat + "," + posLong);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(geoLocation);

    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    } else {
        Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!");
    }
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:26,代码来源:MainActivity.java

示例5: onOptionsItemSelected

import android.content.Intent; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case R.id.action_refresh:
            mWebView.reload();
            return true;
        case R.id.action_copy_url:
            String copyDone = getString(R.string.tip_copy_done);
            Util.copyToClipBoard(this, mWebView.getUrl(), copyDone);
            return true;
        case R.id.action_open_url:
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            Uri uri = Uri.parse(mUrl);
            intent.setData(uri);
            if (intent.resolveActivity(getPackageManager()) != null) {
                startActivity(intent);
            } else {
                showToast(getResources().getString(R.string.tip_open_fail));
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:weixianshishen,项目名称:BeautifulGirls,代码行数:26,代码来源:WebActivity.java

示例6: onClickGallery

import android.content.Intent; //导入方法依赖的package包/类
public void onClickGallery(View view) {
    //Create new intent for selection on photo
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    if (intent.resolveActivity(getPackageManager()) != null) {
        // Bring up gallery to select a photo
        startActivityForResult(intent, PICK_PHOTO_CODE);
    }
}
 
开发者ID:umdcs,项目名称:linkedout_procon,代码行数:9,代码来源:EmployerRegisterActivity.java

示例7: alipayDonate

import android.content.Intent; //导入方法依赖的package包/类
public static void alipayDonate(Context context) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String payUrl = "https://qr.alipay.com/FKX06496G2PCRYR0LXR7BC";
    intent.setData(Uri.parse("alipayqr://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=" + payUrl));
    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);
    } else {
        intent.setData(Uri.parse(payUrl));
        context.startActivity(intent);
    }
}
 
开发者ID:xiaofei-dev,项目名称:SuspendNotification,代码行数:14,代码来源:OpenUtil.java

示例8: submitOrder

import android.content.Intent; //导入方法依赖的package包/类
/**
 * This method is called when the order button is clicked.
 */
public void submitOrder(View view) {

    EditText nameField = findViewById(R.id.name_field);
    String name = nameField.getText().toString();
    Log.v("MainActivity", "Name: " + name);

    // Figure out if the user wants whipped cream topping
    CheckBox whippedCreamCheckBox = findViewById(R.id.whipped_cream_checkbox);
    boolean hasWhippedCream = whippedCreamCheckBox.isChecked();

    // Figure out if the user wants chocolate topping
    CheckBox chocolateCheckBox = findViewById(R.id.chocolate_checkbox);
    boolean hasChocolate = chocolateCheckBox.isChecked();

    // Calculate the price
    int price = calculatePrice(hasWhippedCream, hasChocolate);
    String priceMessage = createOrderSummary(name, price, hasWhippedCream, hasChocolate);

    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_SUBJECT, "Just Java order for " + name);
    intent.putExtra(Intent.EXTRA_TEXT, priceMessage);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}
 
开发者ID:ItalianCoder,项目名称:Google-Developer-Challenge-Scholarship-Android-Basics,代码行数:30,代码来源:MainActivity.java

示例9: onBtnTakePictureClicked

import android.content.Intent; //导入方法依赖的package包/类
@OnClick(R.id.btn_take_picture)
public void onBtnTakePictureClicked() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }
}
 
开发者ID:daeng-id,项目名称:nfkita-mobile,代码行数:8,代码来源:CampustReportActivity.java

示例10: onMailtoLinkClicked

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onMailtoLinkClicked(String address) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{address});
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:10,代码来源:MainActivity.java

示例11: shareText

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 分享文本
 *
 * @param context
 * @param text    分享的文本
 */
public static void shareText(Context context, String text) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("text/*");
    shareIntent.putExtra(Intent.EXTRA_TEXT, text);
    ComponentName componentName = shareIntent.resolveActivity(context.getPackageManager());
    if (componentName != null) {
        context.startActivity(Intent.createChooser(shareIntent, context.getString(R.string.share_to)));
    } else {
        AppToast.showToast("无法分享。");
    }
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:19,代码来源:CommonUtils.java

示例12: onInsertImageUploadClicked

import android.content.Intent; //导入方法依赖的package包/类
@SuppressLint("InlinedApi") // suppressed because PermissionsDispatcher handles API levels for us
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
public void onInsertImageUploadClicked(Action1<String> uploadDoneAction) {
    mImageUploadDoneAction = uploadDoneAction;
    Intent imagePickIntent = new Intent(Intent.ACTION_GET_CONTENT);
    imagePickIntent.addCategory(Intent.CATEGORY_OPENABLE);
    imagePickIntent.setType("image/*");
    if (imagePickIntent.resolveActivity(mActivity.getPackageManager()) != null) {
        startActivityForResult(imagePickIntent, REQUEST_CODE_IMAGE_PICK);
    } else {
        Toast.makeText(mActivity, R.string.intent_no_apps, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:14,代码来源:PostEditFragment.java

示例13: openUri

import android.content.Intent; //导入方法依赖的package包/类
public static void openUri(@NonNull Context context, @NonNull String uri) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);
    } else {
        Toast.makeText(context, R.string.intent_no_apps,
                Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:10,代码来源:AppUtils.java

示例14: showCameraAction

import android.content.Intent; //导入方法依赖的package包/类
private void showCameraAction() {
    if (config.maxNum <= Global.imageList.size()) {
        AppToast.showToast(String.format(getString(R.string.max_num), config.maxNum));
        return;
    }

    if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA)
            != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CODE);
        return;
    }

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    if (cameraIntent.resolveActivity(getActivity().getPackageManager()) != null) {
        tempFile = new File(FileUtils.getRootPath(getActivity()) + File.separator
                + getActivity().getString(R.string.app_name) + "_" + System.currentTimeMillis() + ".jpg");
        // 创建临时照片文件
        FileUtils.createFile(tempFile);

        Uri uri = FileProvider.getUriForFile(getActivity(), FileUtils.getApplicationId(getActivity()) + ".provider", tempFile);

        List<ResolveInfo> resInfoList = getActivity().getPackageManager()
                .queryIntentActivities(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY);
        for (ResolveInfo resolveInfo : resInfoList) {
            String packageName = resolveInfo.activityInfo.packageName;
            getActivity().grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                    | Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }

        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        startActivityForResult(cameraIntent, REQUEST_CAMERA);
    } else {
        AppToast.showToast(R.string.open_camera_failure);
    }
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:37,代码来源:ImageSelectFragment.java

示例15: onShowFileChooser

import android.content.Intent; //导入方法依赖的package包/类
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
    // Double check that we don't have any existing callbacks
    if (mFilePathCallback != null) {
        mFilePathCallback.onReceiveValue(null);
    }
    mFilePathCallback = filePath;

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
            takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
        } catch (IOException ex) {
            // Error occurred while creating the File
            Log.e(TAG, "Unable to create Image File", ex);
        }

        // Continue only if the File was successfully created
        if (photoFile != null) {
            mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(photoFile));
        } else {
            takePictureIntent = null;
        }
    }

    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("*/*");

    Intent[] intentArray;
    if (takePictureIntent != null) {
        intentArray = new Intent[]{takePictureIntent};
    } else {
        intentArray = new Intent[0];
    }

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "File Chooser");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

    startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);

    return true;

}
 
开发者ID:ashutoshbsathe,项目名称:COEP-Moodle-via-Webview,代码行数:51,代码来源:Moodle.java


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