當前位置: 首頁>>代碼示例>>Java>>正文


Java PermissionChecker.checkCallingOrSelfPermission方法代碼示例

本文整理匯總了Java中android.support.v4.content.PermissionChecker.checkCallingOrSelfPermission方法的典型用法代碼示例。如果您正苦於以下問題:Java PermissionChecker.checkCallingOrSelfPermission方法的具體用法?Java PermissionChecker.checkCallingOrSelfPermission怎麽用?Java PermissionChecker.checkCallingOrSelfPermission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.content.PermissionChecker的用法示例。


在下文中一共展示了PermissionChecker.checkCallingOrSelfPermission方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startCameraActivity

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
protected void startCameraActivity() {
    int permissionCheck = PermissionChecker.checkCallingOrSelfPermission(this,
            android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
        Intent photoPickerIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                getOutputMediaFile());
        photoPickerIntent.putExtra("outputFormat",
                Bitmap.CompressFormat.JPEG.toString());
        startActivityForResult(
                Intent.createChooser(photoPickerIntent, getString(R.string.upload_picker_title)),
                CAMERA_CODE);
    } else {
        showMenu(1);
    }
}
 
開發者ID:eventtus,項目名稱:photo-editor-android,代碼行數:17,代碼來源:BaseActivity.java

示例2: loadInBackground

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
@Override
public List<Artist> loadInBackground() {

    List<Artist> artistList = new ArrayList<>();

    if (PermissionChecker.checkCallingOrSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
        Cursor cursor = getContext().getContentResolver().query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, null, null, null, sortorder);
        if (cursor != null && cursor.moveToFirst()) {
            int idCol = cursor.getColumnIndex(BaseColumns._ID);
            int nameCol = cursor.getColumnIndex(MediaStore.Audio.ArtistColumns.ARTIST);
            int albumsNbCol = cursor.getColumnIndex(MediaStore.Audio.ArtistColumns.NUMBER_OF_ALBUMS);
            int tracksNbCol = cursor.getColumnIndex(MediaStore.Audio.ArtistColumns.NUMBER_OF_TRACKS);
            do {
                long id = cursor.getLong(idCol);
                String artistName = cursor.getString(nameCol);
                int albumCount = cursor.getInt(albumsNbCol);
                int trackCount = cursor.getInt(tracksNbCol);
                artistList.add(new Artist(id, artistName, albumCount, trackCount));
            } while (cursor.moveToNext());
            cursor.close();
        }
        if (cursor == null) {
            return Collections.emptyList();
        }
        return artistList;
    } else {
        return null;
    }

}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:31,代碼來源:ArtistLoader.java

示例3: loadInBackground

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
@Override
public List<Playlist> loadInBackground() {
    List<Playlist> playlistList = new ArrayList<>();
    if (PermissionChecker.checkCallingOrSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
        Cursor cursor = getContext().getContentResolver().query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, dataCol, "", null, sortorder);
        if (cursor != null && cursor.moveToFirst()) {
            int idCol = cursor.getColumnIndex(MediaStore.Audio.Playlists._ID);
            int nameCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.NAME);
            do {
                long id = cursor.getLong(idCol);
                String name = cursor.getString(nameCol);

                Playlist playlist = new Playlist();
                playlist.setId(id);
                playlist.setName(name);
                playlistList.add(playlist);
            } while (cursor.moveToNext());
            cursor.close();
        }
        if (cursor == null) {
            return Collections.emptyList();
        }
        return playlistList;
    } else {
        return null;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:28,代碼來源:PlaylistLoaders.java

示例4: loadInBackground

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
@Override
public List<Artist> loadInBackground() {
    List<Artist> artistList = new ArrayList<>();

    if (PermissionChecker.checkCallingOrSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
        Cursor cursor = getContext().getContentResolver().query(MediaStore.Audio.Artists.Albums.getContentUri("external", artistID), null, null, null, sortorder);
        if (cursor != null && cursor.moveToFirst()) {
            int idCol = cursor.getColumnIndex(BaseColumns._ID);
            int nameCol = cursor.getColumnIndex(MediaStore.Audio.Artists.Albums.ARTIST);
            int albumsNbCol = cursor.getColumnIndex(MediaStore.Audio.Artists.Albums.NUMBER_OF_SONGS_FOR_ARTIST);
            int tracksNbCol = cursor.getColumnIndex(MediaStore.Audio.Artists.Albums.NUMBER_OF_SONGS);
            do {
                long id = cursor.getLong(idCol);
                String artistName = cursor.getString(nameCol);
                int albumCount = cursor.getInt(albumsNbCol);
                int trackCount = cursor.getInt(tracksNbCol);
                artistList.add(new Artist(id, artistName, albumCount, trackCount));
            } while (cursor.moveToNext());
            cursor.close();
        }
        if (cursor == null) {
            return Collections.emptyList();
        }
        return artistList;
    } else {
        return null;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:29,代碼來源:ArtistAlbumLoader.java

示例5: loadInBackground

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
@Override
public List<Album> loadInBackground() {
    ArrayList<Album> albums = new ArrayList<>();
    if (PermissionChecker.checkCallingOrSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
        Cursor musicCursor = getContext().getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, datacol, Where, selectionargs, sortorder);
        if (musicCursor != null && musicCursor.moveToFirst()) {
            int titleColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ALBUM);
            int idColumn = musicCursor.getColumnIndex(BaseColumns._ID);
            int artistColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ARTIST);
            int numOfSongsColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS);
            int albumfirstColumn = musicCursor.getColumnIndex(MediaStore.Audio.AlbumColumns.FIRST_YEAR);
            do {
                String albumName = musicCursor.getString(titleColumn);
                long albumId = musicCursor.getLong(idColumn);
                String artistName = musicCursor.getString(artistColumn);
                int year = musicCursor.getInt(albumfirstColumn);
                int no = musicCursor.getInt(numOfSongsColumn);
                Album album = new Album();
                /**
                 * Setting Album Metadata
                 */
                album.setArtistName(artistName);
                album.setAlbumName(albumName);
                album.setId(albumId);
                album.setTrackCount(no);
                album.setYear(year);
                albums.add(album);
            } while (musicCursor.moveToNext());
            musicCursor.close();
        }
        if (musicCursor == null) {
            return Collections.emptyList();
        }
        return albums;
    } else {
        return null;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:39,代碼來源:AlbumLoader.java

示例6: isSystemAlertGranted

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
public static boolean isSystemAlertGranted(@NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        boolean result = PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.SYSTEM_ALERT_WINDOW) == PermissionChecker.PERMISSION_GRANTED;
        if (result || Settings.canDrawOverlays(context)) {
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:13,代碼來源:permissionManager.java

示例7: isAudioRecordGranted

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
public static boolean isAudioRecordGranted(@NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.RECORD_AUDIO) == PermissionChecker.PERMISSION_GRANTED) {
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:12,代碼來源:permissionManager.java

示例8: isWriteSettingsGranted

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
public static boolean isWriteSettingsGranted(@NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int result = PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_SETTINGS);
        if ((result == PermissionChecker.PERMISSION_GRANTED) || Settings.System.canWrite(context)) {
            return true;
        } else if (result == PermissionChecker.PERMISSION_DENIED) {
            return false;
        } else {
            return false;
        }
    }else {
        return true;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:15,代碼來源:permissionManager.java

示例9: isExternalReadStorageGranted

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
public static boolean isExternalReadStorageGranted(@NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:12,代碼來源:permissionManager.java

示例10: writeExternalStorageGranted

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
public static boolean writeExternalStorageGranted(@NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:12,代碼來源:permissionManager.java

示例11: loadInBackground

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
@Override
public List<Song> loadInBackground() {
    List<Song> playlist = new ArrayList<>();
    String sortorder = MediaStore.Audio.Playlists.Members.PLAY_ORDER;
    if (mPlaylistId == 0) {
        return null;
    }
    if (PermissionChecker.checkCallingOrSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
        Cursor cursor = getContext().getContentResolver().query(MediaStore.Audio.Playlists.Members.getContentUri("external", mPlaylistId), sProjection, "", null, sortorder);
        if (cursor != null && cursor.moveToFirst()) {
            int idCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.AUDIO_ID);
            if (idCol == -1) {
                idCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members._ID);
            }
            int titleCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.TITLE);
            int artistCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.ARTIST);
            int albumCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.ALBUM);
            int albumIdCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.ALBUM_ID);
            int trackCol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.TRACK);
            int datacol = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.DATA);
            do {
                long id = cursor.getLong(idCol);
                String title = cursor.getString(titleCol);
                String artist = cursor.getString(artistCol);
                String album = cursor.getString(albumCol);
                long albumId = cursor.getLong(albumIdCol);
                int track = cursor.getInt(trackCol);
                String mSongPath = cursor.getString(datacol);
                Song song = new Song();
                /*
                 Setup metadata of playlist
                */
                song.setAlbum(album);
                song.setmSongPath(mSongPath);
                song.setArtist(artist);
                song.setId(id);
                song.setAlbumId(albumId);
                song.setTrackNumber(track);
                song.setTitle(title);
                playlist.add(song);
            } while (cursor.moveToNext());
            cursor.close();
        }
        if (cursor == null) {
            Collections.emptyList();
        }
        return playlist;
    } else {
        return null;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:52,代碼來源:PlaylistLoader.java

示例12: getSongData

import android.support.v4.content.PermissionChecker; //導入方法依賴的package包/類
public static Song getSongData(String sortOrder, @NonNull Context context, String path) {
    if (path == null) {
        return null;
    }
    Song song = new Song();
    if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED) {
        Cursor cursor = context.getContentResolver().query(Media.EXTERNAL_CONTENT_URI, null, MediaStore.Audio.Media.DATA + " like ? ", new String[]{"%" + path + "%"}, sortOrder);
        if (cursor != null && cursor.moveToFirst()) {
            int idCol = cursor.getColumnIndex(MediaStore.Audio.Media._ID);
            int titleCol = cursor.getColumnIndex(MediaStore.Audio.Media.TITLE);
            int artistCol = cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST);
            int albumCol = cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM);
            int albumIdCol = cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID);
            int trackCol = cursor.getColumnIndex(MediaStore.Audio.Media.TRACK);
            int datacol = cursor.getColumnIndex(MediaStore.Audio.Media.DATA);

            /**
             * @return songs metadata
             */
            long id = cursor.getLong(idCol);
            String title = cursor.getString(titleCol);
            String artist = cursor.getString(artistCol);
            String album = cursor.getString(albumCol);
            long albumId = cursor.getLong(albumIdCol);
            int track = cursor.getInt(trackCol);
            String mSongPath = cursor.getString(datacol);

            song.setAlbum(album);
            song.setmSongPath(mSongPath);
            song.setArtist(artist);
            song.setId(id);
            song.setAlbumId(albumId);
            song.setTrackNumber(track);
            song.setTitle(title);
        }
        if (cursor != null) {
            cursor.close();
        }
    } else {
        Log.e("DefaultSongLoader", "No read permissions");
    }
    return song;
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:44,代碼來源:Helper.java


注:本文中的android.support.v4.content.PermissionChecker.checkCallingOrSelfPermission方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。