Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Setelan Cepat adalah kartu yang ditampilkan di panel Setelan Cepat.
Pengguna dapat mengetuk kartu ini untuk menyelesaikan tugas berulang dengan cepat.
Dokumen ini menunjukkan cara membuat kartu Setelan Cepat kustom untuk Kode QR
pembayaran.
Untuk meluncurkan pembayaran Kode QR, isi metode onClick(). Mengetuk lama
kartu meminta pengguna melihat layar Info Aplikasi. Untuk mengganti perilaku ini
dan sebagai gantinya, luncurkan aktivitas untuk menyetel preferensi, tambahkan
<intent-filter> ke salah satu aktivitas Anda dengan
ACTION_QS_TILE_PREFERENCES.
Kotlin
importandroid.service.quicksettings.TileService// Called when the user taps on your tile in an active or inactive state.overridefunonClick(){// Create Intent, replace MainActivity::class.java with QR Code Activityvalintent=Intent(this,MainActivity::class.java)// Create PendingIntentvalpendingIntent=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
importandroid.service.quicksettings.TileService;// Called when the user taps on your tile in an active or inactive state.@OverridepublicvoidonClick(){// Create Intent, replace MainActivity.class with QR Code ActivityIntentintent=newIntent(MyQSTileService.this,MainActivity.class);// Create PendingIntentPendingIntentpendingIntent=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);}}
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],null,["# Create a QR Code Payment Quick Settings tile\n\nQuick Settings are tiles displayed in the [Quick Settings panel](https://support.google.com/android/answer/9083864).\nUsers can tap these tiles to quickly complete recurring tasks.\nThis document shows you how to create a custom Quick Settings tile for QR Code\npayments.\n\nBefore continuing, be sure you're familiar with general instructions and best\npractices for [creating custom Quick Settings tiles for your app](/develop/ui/views/quicksettings-tiles).\n\nTo [create your tile](/develop/ui/views/quicksettings-tiles#create-tile), follow these steps:\n\n1. [Create your custom icon](/develop/ui/views/quicksettings-tiles#create-custom).\n2. [Create and declare your `TileService`](/develop/ui/views/quicksettings-tiles#create-declare-tileservice).\n\n | **Note:** At this point, your custom tile service will appear in the Quick Settings menu. In order to see your custom tile upon pull down, [edit and\n | rearrange your tiles](https://support.google.com/android/answer/9083864).\n3. To launch the QR Code payment, fill in the `onClick()` method. Long-tapping\n a tile prompts the App Info screen for the user. To override this behavior\n and instead launch an activity for setting preferences, add an\n `\u003cintent-filter\u003e` to one of your activities with\n [`ACTION_QS_TILE_PREFERENCES`](/reference/android/service/quicksettings/TileService.html?utm_campaign=adp_series_quicksettingstiles_092916&utm_source=medium&utm_medium=blog#ACTION_QS_TILE_PREFERENCES).\n\n ### Kotlin\n\n ```kotlin\n import android.service.quicksettings.TileService\n\n // Called when the user taps on your tile in an active or inactive state.\n override fun onClick() {\n // Create Intent, replace MainActivity::class.java with QR Code Activity\n val intent = Intent(this, MainActivity::class.java)\n // Create PendingIntent\n val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)\n if (android.os.Build.VERSION.SDK_INT \u003e= android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {\n startActivityAndCollapse(pendingIntent)\n } else {\n intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)\n startActivityAndCollapse(intent)\n }\n }\n ```\n\n ### Java\n\n ```java\n import android.service.quicksettings.TileService;\n\n // Called when the user taps on your tile in an active or inactive state.\n @Override\n public void onClick() {\n // Create Intent, replace MainActivity.class with QR Code Activity\n Intent intent = new Intent(MyQSTileService.this, MainActivity.class);\n // Create PendingIntent\n PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE);\n if (VERSION.SDK_INT \u003e= VERSION_CODES.UPSIDE_DOWN_CAKE) {\n startActivityAndCollapse(pendingIntent);\n } else {\n intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n startActivityAndCollapse(intent);\n }\n }\n ```\n4. To protect users' sensitive payment information, [perform only safe actions\n on securely-locked devices](/develop/ui/views/quicksettings-tiles#perform-only).\n\n ### Kotlin\n\n ```kotlin\n import android.service.quicksettings.TileService\n\n override fun onClick() {\n val intent = Intent(this, MainActivity::class.java)\n val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)\n\n // ...\n\n if (isSecure()) {\n startActivityAndCollapse(pendingIntent)\n } else {\n unlockAndRun {\n startActivityAndCollapse(pendingIntent)\n }\n }\n // ...\n }\n ```\n\n ### Java\n\n ```java\n import android.service.quicksettings.TileService;\n\n @Override\n public void onClick() {\n Intent intent = new Intent(MyQSTileService.this, MainActivity.class);\n PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE);\n ...\n if (isSecure()) {\n startActivityAndCollapse(pendingIntent);\n } else {\n unlockAndRun(new Runnable() {\n @Override\n public void run() {\n startActivityAndCollapse(pendingIntent);\n }\n });\n }\n ...\n }\n ```\n5. When first introducing this feature, [prompt the user to add your\n tile](/develop/ui/views/quicksettings-tiles#prompt-user)."]]