Reputation: 1
I followed this tutorial: https://www.youtube.com/watch?v=1D1Jo1sLBMo&t=320s&ab_channel=EasyTuto but I can't get my playlist or the authorization request but being on Android 13 I did the tests below
I replaced "READ EXTERNAL STORAGE" on the manifest and on main activity by "READ MEDIA AUDIO" Now, I have the window that asks for authorization, but even if I indicate OK, my playlist is not displayed and it tells me the text "MUSIC NOT FOUND"
for info: android studio code java
Who can tell me what the problem is... I've been at this for days, I'm lost.... thank you everyone
Upvotes: 0
Views: 33
Reputation: 2042
I struggled with different versions/permissions for a long time. In the end my configuration is Manifest:
and java code I called "Startup" (not full method extract) String[] permissions ={READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE, READ_MEDIA_AUDIO};
if (ContextCompat.checkSelfPermission(this, Arrays.toString(permissions))
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, permissions, MY_PERMISSIONS_REQUEST);
} else {
first_messageDialog(mContext.getString(R.string.attention), mContext.getString(R.string.androidQ));
Intent i = new Intent(this, PlaylistMainActivity.class);
startActivity(i);
this.finish();
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case MY_PERMISSIONS_REQUEST:
if (grantResults.length > 0) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED
|| (grantResults[1] == PackageManager.PERMISSION_GRANTED)
|| (grantResults[2] == PackageManager.PERMISSION_GRANTED))
{
// Log.i("PERMISSION RESULTS", "Read Storage " + grantResults[0] + " Write Storage " + grantResults[1]);
Intent i = new Intent(this, PlaylistMainActivity.class);
startActivity(i);
this.finish();
}
break;
}
This does away with all the stupid version checking and just gets on with the job if appropriate.
Upvotes: 0