Page 288 - MDP2022-3
P. 288

//  TODO  :  퍼미션  허용  시  할  동작
            mNum  =  mEditNumber.getText().toString();
            String  tel  =  "tel:"  +  mNum;
            startActivity(new  Intent("android.intent.action.CALL",  Uri.parse(tel)));
            }
            }
            }
            @Override
            public  void  onClick(View  v)  {
            mNum  =  mEditNumber.getText().toString();
            String  tel  =  "tel:"  +  mNum;
            switch  (v.getId()){
            case  R.id.btnCall:
            if(ActivityCompat.checkSelfPermission(this,  Manifest.permission.CALL_PHONE)  ==
            PackageManager.PERMISSION_DENIED)  {
            ActivityCompat.requestPermissions(this,  new  String[]{Manifest.permission.CALL_PHONE},  3924);
            }else{
            startActivity(new  Intent("android.intent.action.CALL",  Uri.parse(tel)));
            }
            break;
            case  R.id.btnDialog:
            startActivity(new  Intent("android.intent.action.DIAL",  Uri.parse(tel)));
            break;
            }
            }}
            activity_main.틔
            <?xml  version="1.0"  encoding="utf-8"?>
            <androidx.constraintlayout.widget.ConstraintLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".MainActivity">


            <TextView
            android:id="@+id/textView"
            android:layout_width="173dp"
            android:layout_height="49dp"
            android:text="실시간CCTV"
            android:textColor="#99CCFF"
            android:textSize="30dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.141"  />
            <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/GalleryButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/left_btn_background"
            android:drawableLeft="@drawable/icon1"
            android:onClick="gallery"
            android:paddingLeft="20dp"
            android:text="갤러리"
            android:textColor="#ffffff"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.84"  />

            <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/CameraButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/right_btn_background"
   283   284   285   286   287   288   289   290   291   292   293