Mavzu: Android ilovada Service komponentasi. Reja: Kontaktlar bilan ishlash. Kontaktlar qo'shililishi. Kontent provayderni yaratish. Json bilan ishlash


Download 55.47 Kb.
bet3/4
Sana22.06.2023
Hajmi55.47 Kb.
#1647396
1   2   3   4
Bog'liq
6-Mavzu (2)

android:textSize="18sp" app:layout_constraintBottom_toTopOf="@id/contactList" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" />

Kontaktlar ro'yxatini ko'rsatish uchun ListView elementidan foydalanamiz. Va MainActivity sinfida biz kontaktlarni olamiz:

  • package com.example.contactsapp;
  • import androidx.appcompat.app.AppCompatActivity;
  • import androidx.core.app.ActivityCompat;
  • import androidx.core.content.ContextCompat;
  • import android.Manifest;
  • import android.content.ContentResolver;
  • import android.content.pm.PackageManager;
  • import android.database.Cursor;
  • import android.os.Bundle;

import android.provider.ContactsContract;

  • import android.provider.ContactsContract;
  • import android.widget.ArrayAdapter;
  • import android.widget.ListView;
  • import android.widget.Toast;
  • import java.util.ArrayList;
  • public class MainActivity extends AppCompatActivity {
  • private static final int REQUEST_CODE_READ_CONTACTS=1;
  • private static boolean READ_CONTACTS_GRANTED =false;
  • @Override
  • protected void onCreate(Bundle savedInstanceState) {
  • super.onCreate(savedInstanceState);
  • setContentView(R.layout.activity_main);
  • // ruxsat olamiz
  • int hasReadContactPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS);

Download 55.47 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling