美文网首页
Android打开系统APP

Android打开系统APP

作者: 灰灰手记 | 来源:发表于2017-10-09 19:48 被阅读47次
打开 Camera
    private void launchCamera() {
        Intent intent = new Intent();
        intent.setAction(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
        startActivity(intent);
    }
打开 Gallery
    private void launchGallery() {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setType("image/*");
        //intent.setData(Uri.parse("content://media/external/images/media"));
        startActivity(intent);
    }
打开 Music
    private void launchMusic() {
        Intent intent = new Intent();
        intent.setAction(MediaStore.INTENT_ACTION_MUSIC_PLAYER);
        startActivity(intent);
    }
或
    private void launchMusic() {
        startActivity(Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_MUSIC));
    }
打开 Video
    private void launchVideo() {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);

        intent.setType("video/*");
        startActivity(intent);
    }
打开 Settings
    private void launchSettings() {
        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_SETTINGS);
        startActivity(intent);
    }

抽离公共部分
    private void launchApp(String action, String type, String category) {
        Intent intent = new Intent(action);
        if (null != type) {
            intent.setType(type);
        }
        if (null != category && !intent.hasCategory(category)) {
            intent.addCategory(category);
        }
        startActivity(intent);
    }

打开设置子项界面

Android开发中调用系统设置界面

相关文章

网友评论

      本文标题:Android打开系统APP

      本文链接:https://www.haomeiwen.com/subject/dagpyxtx.html