Code example for Context

Methods: getPackageManager

0
    private ResolveInfo resolveMime(String mime) {
        Intent viewIntent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.fromParts("file", MP3_FILE, null);
 
        viewIntent.setDataAndType(uri, mime);
        return mContext.getPackageManager().resolveActivity(
                viewIntent, PackageManager.MATCH_DEFAULT_ONLY);
    } 
 
    // Helper method to check the media playback activity handles the given mime type. 
    // @param mime type to test for 
    private void assertMediaPlaybackActivityHandles(String mime) throws Exception {
        ResolveInfo ri = resolveMime(mime);
 
        assertNotNull(ri);
    } 
 
    // Helper method to check that NO activity handles the given mime type. 
    // @param mime type to test for 
    private void assertNoActivityHandles(String mime) throws Exception {
        assertNull(resolveMime(mime));