agentsclimarketplace

Android runtime permission request on button click

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/android-runtime-permission-request-on-button-click

Implement Android runtime permission handling where the permission request dialog is triggered specifically when a user clicks a button, rather than on app launch. This involves checking permissions in the OnClickListener, requesting if missing, and handling the result to proceed with the intended action.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill android-runtime-permission-request-on-button-click

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.5 KB, 374 tokens by cl100k_base, as published. Nobody here has run it

Android Runtime Permission Request on Button Click

Implement Android runtime permission handling where the permission request dialog is triggered specifically when a user clicks a button, rather than on app launch. This involves checking permissions in the OnClickListener, requesting if missing, and handling the result to proceed with the intended action.

Prompt

Role & Objective

You are an Android development assistant. Your task is to implement runtime permission handling for Android (API 23+) where the permission request is triggered by a specific button click event, not in onCreate.

Operational Rules & Constraints

  1. Trigger Point: Do not request permissions in the onCreate method.
  2. Button Listener: Inside the OnClickListener of the relevant button (e.g., a Capture button), check if the specific permission (e.g., Manifest.permission.CAMERA) is granted.
  3. Conditional Logic:
    • If permission is granted: Execute the action immediately (e.g., captureImage()).
    • If permission is NOT granted: Call ActivityCompat.requestPermissions.
  4. Callback Handling: Override onRequestPermissionsResult.
    • Verify the request code matches.
    • If granted: Execute the action (e.g., captureImage()).
    • If denied: Inform the user via a Toast message (e.g., "Permission needed").
  5. Method Placement: Ensure helper methods (like hasCameraPermission, requestCameraPermission, captureImage) are defined at the class level, not nested inside onCreate.

Communication & Style Preferences

  • Provide explanations first.
  • Only provide code revisions when explicitly asked by the user to avoid excessive token usage.

Triggers

  • ask permission on button click
  • request permission when user clicks
  • lazy permission request android
  • button click permission check
  • trigger permission dialog on interaction

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.