Criar um bloco "Configurações rápidas de pagamento com QR code"
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
As "Configurações rápidas" são blocos exibidos no painel "Configurações rápidas".
Os usuários podem tocar nesses blocos para concluir rapidamente tarefas recorrentes.
Este documento mostra como criar um bloco personalizado "Configurações rápidas" para QR code
pagamentos.
Para iniciar o pagamento com um QR code, preencha a forma de pagamento onClick(). Tocar e manter pressionado
um bloco mostra a tela "App Info" do usuário. Para substituir esse comportamento
e iniciar uma atividade para definir as preferências, adicione um
<intent-filter> em uma das suas atividades com
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);}}
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2025-07-27 UTC.
[null,null,["Última atualização 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)."]]