Best practices

Gemini's answers differ based on how you ask your question. Here are some tips on how to optimize the answers from Gemini:

  • Be specific. If there are certain libraries, APIs, or approaches that you'd like to use, include them in your question.
    How do I add camera support to my app using CameraX?
    How do I add camera support to my app?
  • Describe the structure of the desired answer. If you want to insert code generated by Gemini into your app and need it in a certain format, give it those instructions.
    Insert comments into this code. Use double slashes for the comments, and put each comment above the line of code it describes.
    Write code comments for this code.
  • Break up complex requests into a series of simpler questions. Especially when you're asking for code, asking a series of simpler questions yields a more comprehensive answer overall.
    1. Give me the MainActivity.kt file for an app with a login screen.
    2. Can you add a class that represents a user profile?
    3. Can you add code that supports multiple user profiles?
    How do I create an app with a login screen that supports multiple user profiles?