[General Questions and Answers] xavicoel:
I want to display in sequence the permissions for each item. I have the following code: I have my main activity first and i show you my other code for the permissions which is the same for each item.

package com.example.crediluca;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.example.crediluca.gps.Permissions;

import com.example.crediluca.extraer.extraePersonas;

import com.example.crediluca.extraer.extraeLlamadas;

public class MainActivity extends AppCompatActivity {

private static final String TAG = MainActivity.class.getSimpleName();

private static final int REQUEST_PERMISSIONS_REQUEST_CODE = 34;

// Permisos para la ubicacion

private Permissions permissions_gps = new Permissions(this);

//Permisos para extraer contactos

private extraePersonas personas_contacts = new extraePersonas(this);

//Permisos para extraer llamadas

private extraeLlamadas llamadas_log = new extraeLlamadas(this);

// private extraePersonas extraigoPersona = new extraePersonas(context:this) ;

@override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// ex.fetchContacts();

//ex.getCallDetails();

if (! permissions_gps.checkPermissions())

{

permissions_gps.requestPermissions();

//permissions.notificationResult();

}

if (! personas_contacts.checkPermissions())

{

personas_contacts.requestPermissions();

}

if (! llamadas_log.checkPermissions())

{

llamadas_log.requestPermissions();

}

//Vlidacion de los permisos de ubicacion

}

}

//--------------------------------------------------------------ANOTHER FILE which is basically the same permissions for my other items------------------------------------------------------------------------------------//

public class extraePersonas extends AppCompatActivity {

private static final String TAG = MainActivity.class.getSimpleName();

private static final int REQUEST_PERMISSIONS_REQUEST_CODE = 79;

private Context context;

//public extraePersonas(Context context) {this.context = context; }

public extraePersonas(Activity activity) {this.context = activity; }

//------------------------------

public boolean checkPermissions() {

int variablePersona = ActivityCompat.checkSelfPermission(

(Activity) context, Manifest.permission.READ_CONTACTS);

return (variablePersona == PackageManager.PERMISSION_GRANTED);

}

public void requestPermissions() {

boolean shouldProvideRationale = checkPermissions();

if (shouldProvideRationale) {

Log.i(TAG, "Mostrando los permisos que debe otorgar.");

Snackbar.make(

findViewById(R.id.activity_main),

R.string.permission_rationale,

Snackbar.LENGTH_INDEFINITE)

.setAction(R.string.ok, new View.OnClickListener() {

@override

public void onClick(View view) {

// Peticion de permisos

ActivityCompat.requestPermissions((Activity) context,

new String[] {

Manifest.permission.READ_CONTACTS,

},

REQUEST_PERMISSIONS_REQUEST_CODE);

}

})

.show();

} else {

Log.i(TAG, "Pidiendo permisos");

ActivityCompat.requestPermissions((Activity) context,

new String[] {

Manifest.permission.READ_CONTACTS },

REQUEST_PERMISSIONS_REQUEST_CODE);

}

}

//---------------------------------

//-------------------------------------

public void fetchContacts() {

String phoneNumber = null;

String email = null;

Uri CONTENT_URI = ContactsContract.Contacts.CONTENT_URI;

String _ID = ContactsContract.Contacts._ID;

String DISPLAY_NAME = ContactsContract.Contacts.DISPLAY_NAME;

String HAS_PHONE_NUMBER = ContactsContract.Contacts.HAS_PHONE_NUMBER;

Uri PhoneCONTENT_URI = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;

String Phone_CONTACT_ID = ContactsContract.CommonDataKinds.Phone.CONTACT_ID;

String NUMBER = ContactsContract.CommonDataKinds.Phone.NUMBER;

Uri EmailCONTENT_URI = ContactsContract.CommonDataKinds.Email.CONTENT_URI;

String EmailCONTACT_ID = ContactsContract.CommonDataKinds.Email.CONTACT_ID;

String DATA = ContactsContract.CommonDataKinds.Email.DATA;

StringBuffer output = new StringBuffer();

Cursor cursor = context.getContentResolver().query(CONTENT_URI, null, null, null, null);

// Loop for every contact in the phone

if (cursor.getCount() > 0) {

while (cursor.moveToNext()) {

String contact_id = cursor.getString(cursor.getColumnIndex(_ID));

String name = cursor.getString(cursor.getColumnIndex(DISPLAY_NAME));

int hasPhoneNumber = Integer.parseInt(cursor.getString(cursor.getColumnIndex(HAS_PHONE_NUMBER)));

if (hasPhoneNumber > 0) {

output.append("\n First Name:" + name);

Log.i("@codekul", "Name - " + name);

// Query and loop for every phone number of the contact

Cursor phoneCursor = context.getContentResolver().query(PhoneCONTENT_URI, null, Phone_CONTACT_ID + " = ?", new String[]{contact_id}, null);

while (phoneCursor.moveToNext()) {

phoneNumber = phoneCursor.getString(phoneCursor.getColumnIndex(NUMBER));

output.append("\n Phone number:" + phoneNumber);

Log.i("@codekul", "Phone number: " + phoneNumber);

}

phoneCursor.close();

// Query and loop for every email of the contact

Cursor emailCursor = context.getContentResolver().query(EmailCONTENT_URI, null, EmailCONTACT_ID + " = ?", new String[]{contact_id}, null);

while (emailCursor.moveToNext()) {

email = emailCursor.getString(emailCursor.getColumnIndex(DATA));

output.append("\nEmail:" + email);

Log.i("@codekul", "Email: " + email);

}

emailCursor.close();

}

output.append("\n");

}

}

}

}