QR 코드 결제 빠른 설정 타일 만들기

빠른 설정은 빠른 설정 패널에 표시되는 타일입니다. 사용자는 이러한 타일을 탭하여 반복되는 작업을 빠르게 완료할 수 있습니다. 이 문서에서는 QR 코드 결제를 위한 맞춤 빠른 설정 타일을 만드는 방법을 보여줍니다.

계속하기 전에 앱의 맞춤 빠른 설정 타일 만들기에 관한 일반적인 안내와 권장사항을 숙지해야 합니다.

카드를 만들려면 다음 단계를 따르세요.

  1. 맞춤 아이콘을 만듭니다.
  2. TileService를 만들고 선언합니다.

  3. QR 코드 결제를 시작하려면 onClick() 수단을 입력하세요. 카드를 길게 탭하면 앱 정보 화면이 표시됩니다. 이 동작을 재정의하고 대신 환경설정 설정을 위한 활동을 실행하려면 ACTION_QS_TILE_PREFERENCES를 사용하여 활동 중 하나에 <intent-filter>를 추가합니다.

    Kotlin

    import android.service.quicksettings.TileService
    
    // Called when the user taps on your tile in an active or inactive state.
    override fun onClick() {
       // Create Intent, replace MainActivity::class.java with QR Code Activity
       val intent = Intent(this, MainActivity::class.java)
       // Create PendingIntent
       val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)
       if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
         startActivityAndCollapse(pendingIntent)
       } else {
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
         startActivityAndCollapse(intent)
       }
    }
    

    Java

    import android.service.quicksettings.TileService;
    
    // Called when the user taps on your tile in an active or inactive state.
    @Override
    public void onClick() {
     // Create Intent, replace MainActivity.class with QR Code Activity
     Intent intent = new Intent(MyQSTileService.this, MainActivity.class);
     // Create PendingIntent
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE);
     if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
       startActivityAndCollapse(pendingIntent);
     } else {
       intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       startActivityAndCollapse(intent);
     }
    }
    
  4. 사용자의 민감한 결제 정보를 보호하려면 안전하게 잠긴 기기에서만 안전한 작업을 실행하세요.

    Kotlin

    import android.service.quicksettings.TileService
    
    override fun onClick() {
       val intent = Intent(this, MainActivity::class.java)
       val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)
    
       // ...
    
       if (isSecure()) {
           startActivityAndCollapse(pendingIntent)
       } else {
           unlockAndRun {
               startActivityAndCollapse(pendingIntent)
           }
       }
       // ...
    }
    

    Java

    import android.service.quicksettings.TileService;
    
    @Override
    public void onClick() {
     Intent intent = new Intent(MyQSTileService.this, MainActivity.class);
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE);
     ...
     if (isSecure()) {
       startActivityAndCollapse(pendingIntent);
     } else {
       unlockAndRun(new Runnable() {
         @Override
         public void run() {
           startActivityAndCollapse(pendingIntent);
         }
       });
      }
     ...
    }
    
  5. 이 기능을 처음 도입할 때 사용자에게 카드를 추가하라는 메시지를 표시합니다.