{"id":"62073500-104e-4b67-ac15-32d55a173b72","shortId":"G6ZDwS","kind":"skill","title":"cometchat-android-v5-placement","tagline":"Where to put CometChat in your Android app — Activity, Fragment, BottomSheet, Dialog, Tab, or embedded patterns.","description":"> **Companion skills:** `cometchat-android-v5-core` covers init and login;\n> `cometchat-android-v5-components` provides the component catalog.\n\n## Purpose\n\nThis skill teaches WHERE to put CometChat in an existing Android project. It covers six placement patterns: dedicated Activity, Fragment, BottomSheet, Dialog, Tab/ViewPager, and embedded view. Each pattern includes step-by-step instructions and code examples in both Java and Kotlin.\n\n---\n\n## Use this skill when\n\n- Integrating CometChat into an existing Android app\n- Deciding between Activity vs Fragment vs BottomSheet\n- \"Where should I put the chat screen?\"\n- \"How do I add chat as a tab?\"\n- \"How do I show chat in a bottom sheet?\"\n\n## Do not use this skill when\n\n- Setting up init/login → use `cometchat-android-v5-core`\n- Looking up component APIs → use `cometchat-android-v5-components`\n- Customizing appearance → use `cometchat-android-v5-theming`\n\n---\n\n## 1. Placement recommendation\n\n| User intent | Recommended placement | Why |\n|---|---|---|\n| Messaging app | Dedicated Activity with bottom tabs | Full-screen chat experience |\n| Marketplace | Chat button → new Activity | Separate context from product browsing |\n| SaaS / dashboard | Fragment in existing Activity | Chat alongside other features |\n| Social / community | ViewPager + BottomNav tabs | Multi-section messenger |\n| Support / helpdesk | BottomSheet overlay | Non-intrusive, dismissible |\n| Quick reply | Dialog | Lightweight, modal |\n| Embedded widget | View in existing layout | Inline chat within a screen |\n\n---\n\n## 2. Pattern A — Dedicated Activity\n\nThe simplest and most common pattern. A full-screen Activity for the message view.\n\n**MessagesActivity layout (`activity_messages.xml`):**\n```xml\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\">\n\n    <com.cometchat.chatuikit.messageheader.CometChatMessageHeader\n        android:id=\"@+id/header\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\" />\n\n    <com.cometchat.chatuikit.messagelist.CometChatMessageList\n        android:id=\"@+id/messageList\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\" />\n\n    <com.cometchat.chatuikit.messagecomposer.CometChatMessageComposer\n        android:id=\"@+id/composer\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\" />\n</LinearLayout>\n```\n\n**Java:**\n```java\npublic class MessagesActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_messages);\n\n        CometChatMessageHeader header = findViewById(R.id.header);\n        CometChatMessageList messageList = findViewById(R.id.messageList);\n        CometChatMessageComposer composer = findViewById(R.id.composer);\n\n        String uid = getIntent().getStringExtra(\"uid\");\n        String guid = getIntent().getStringExtra(\"guid\");\n\n        if (uid != null) {\n            CometChat.getUser(uid, new CometChat.CallbackListener<User>() {\n                @Override\n                public void onSuccess(User user) {\n                    header.setUser(user);\n                    messageList.setUser(user);\n                    composer.setUser(user);\n                }\n                @Override\n                public void onError(CometChatException e) { }\n            });\n        } else if (guid != null) {\n            CometChat.getGroup(guid, new CometChat.CallbackListener<Group>() {\n                @Override\n                public void onSuccess(Group group) {\n                    header.setGroup(group);\n                    messageList.setGroup(group);\n                    composer.setGroup(group);\n                }\n                @Override\n                public void onError(CometChatException e) { }\n            });\n        }\n\n        header.setBackIconVisibility(View.VISIBLE);\n        header.setOnBackPress(() -> finish());\n    }\n}\n```\n\n**Kotlin:**\n```kotlin\nclass MessagesActivity : AppCompatActivity() {\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_messages)\n\n        val header = findViewById<CometChatMessageHeader>(R.id.header)\n        val messageList = findViewById<CometChatMessageList>(R.id.messageList)\n        val composer = findViewById<CometChatMessageComposer>(R.id.composer)\n\n        val uid = intent.getStringExtra(\"uid\")\n        val guid = intent.getStringExtra(\"guid\")\n\n        when {\n            uid != null -> CometChat.getUser(uid, object : CometChat.CallbackListener<User>() {\n                override fun onSuccess(user: User) {\n                    header.setUser(user)\n                    messageList.setUser(user)\n                    composer.setUser(user)\n                }\n                override fun onError(e: CometChatException) { }\n            })\n            guid != null -> CometChat.getGroup(guid, object : CometChat.CallbackListener<Group>() {\n                override fun onSuccess(group: Group) {\n                    header.setGroup(group)\n                    messageList.setGroup(group)\n                    composer.setGroup(group)\n                }\n                override fun onError(e: CometChatException) { }\n            })\n        }\n\n        header.setBackIconVisibility(View.VISIBLE)\n        header.setOnBackPress { finish() }\n    }\n}\n```\n\n---\n\n## 3. Pattern B — Fragment\n\nEmbed chat in a Fragment within an existing Activity. Useful for SaaS apps or multi-pane layouts.\n\n**Java:**\n```java\npublic class ChatFragment extends Fragment {\n    @Override\n    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {\n        View view = inflater.inflate(R.layout.fragment_chat, container, false);\n\n        CometChatConversations conversations = view.findViewById(R.id.conversations);\n        conversations.setOnItemClick((v, position, conversation) -> {\n            // Navigate to messages — either replace fragment or start Activity\n        });\n\n        return view;\n    }\n}\n```\n\n**Kotlin:**\n```kotlin\nclass ChatFragment : Fragment() {\n    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {\n        val view = inflater.inflate(R.layout.fragment_chat, container, false)\n\n        val conversations = view.findViewById<CometChatConversations>(R.id.conversations)\n        conversations.setOnItemClick { v, position, conversation ->\n            // Navigate to messages — either replace fragment or start Activity\n        }\n\n        return view\n    }\n}\n```\n\n---\n\n## 4. Pattern C — BottomSheet\n\nShow chat as a bottom sheet overlay. Good for support/helpdesk.\n\n**Java:**\n```java\nBottomSheetDialog bottomSheet = new BottomSheetDialog(this);\nView view = getLayoutInflater().inflate(R.layout.bottom_sheet_chat, null);\n\nCometChatMessageList messageList = view.findViewById(R.id.messageList);\nCometChatMessageComposer composer = view.findViewById(R.id.composer);\n\nmessageList.setUser(user);\ncomposer.setUser(user);\n\nbottomSheet.setContentView(view);\nbottomSheet.show();\n```\n\n**Kotlin:**\n```kotlin\nval bottomSheet = BottomSheetDialog(this)\nval view = layoutInflater.inflate(R.layout.bottom_sheet_chat, null)\n\nval messageList = view.findViewById<CometChatMessageList>(R.id.messageList)\nval composer = view.findViewById<CometChatMessageComposer>(R.id.composer)\n\nmessageList.setUser(user)\ncomposer.setUser(user)\n\nbottomSheet.setContentView(view)\nbottomSheet.show()\n```\n\n---\n\n## 5. Pattern D — Bottom Navigation Tabs\n\nFull messenger with Conversations, Users, Groups, and Calls as tabs.\n\n**Java:**\n```java\nbinding.bottomNavigationView.setOnItemSelectedListener(item -> {\n    Fragment fragment;\n    int id = item.getItemId();\n    if (id == R.id.nav_chats) {\n        fragment = new ChatsFragment();      // Contains CometChatConversations\n    } else if (id == R.id.nav_users) {\n        fragment = new UsersFragment();      // Contains CometChatUsers\n    } else if (id == R.id.nav_groups) {\n        fragment = new GroupsFragment();     // Contains CometChatGroups\n    } else if (id == R.id.nav_calls) {\n        fragment = new CallsFragment();      // Contains CometChatCallLogs\n    } else {\n        return false;\n    }\n    getSupportFragmentManager().beginTransaction()\n        .replace(R.id.fragment_container, fragment)\n        .commit();\n    return true;\n});\n```\n\n---\n\n## Hard rules\n\n- **Always set `User` or `Group` on message components.** `CometChatMessageList`, `CometChatMessageComposer`, and `CometChatMessageHeader` require either `setUser()` or `setGroup()` — never both, never neither.\n- **Fetch the `User`/`Group` object before setting it.** Use `CometChat.getUser(uid)` or `CometChat.getGroup(guid)` — don't construct objects manually.\n- **Set back icon visibility on `CometChatMessageHeader`.** The method is `setBackIconVisibility()`. Default is `GONE`. Set to `VISIBLE` when the user needs to navigate back.\n- **Register the Activity in `AndroidManifest.xml`.** Every new Activity needs a manifest entry.","tags":["cometchat","android","placement","skills","agent-skills","ai-agent","chat","claude-code","cursor","messaging","nextjs","react"],"capabilities":["skill","source-cometchat","skill-cometchat-android-v5-placement","topic-agent-skills","topic-ai-agent","topic-chat","topic-claude-code","topic-cometchat","topic-cursor","topic-messaging","topic-nextjs","topic-react","topic-react-native","topic-ui-kit"],"categories":["cometchat-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/cometchat/cometchat-skills/cometchat-android-v5-placement","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add cometchat/cometchat-skills","source_repo":"https://github.com/cometchat/cometchat-skills","install_from":"skills.sh"}},"qualityScore":"0.463","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 27 github stars · SKILL.md body (9,238 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:04:45.108Z","embedding":null,"createdAt":"2026-05-07T13:05:03.961Z","updatedAt":"2026-05-18T19:04:45.108Z","lastSeenAt":"2026-05-18T19:04:45.108Z","tsv":"'1':160 '2':233 '3':436 '4':542 '5':614 'activ':14,61,98,171,184,195,237,248,448,498,539,757,762 'activity_messages.xml':255 'add':113 'alongsid':197 'alway':692 'android':3,12,26,35,53,94,139,149,157 'androidmanifest.xml':759 'api':145 'app':13,95,169,452 'appcompatact':263,356 'appear':153 'b':438 'back':733,754 'begintransact':682 'binding.bottomnavigationview.setonitemselectedlistener':632 'bottom':125,173,550,617 'bottomnav':203 'bottomsheet':16,63,102,211,545,559,589 'bottomsheet.setcontentview':583,611 'bottomsheet.show':585,613 'bottomsheetdialog':558,561,590 'brows':189 'bundl':268,361,473,514 'button':182 'c':544 'call':627,672 'callsfrag':675 'catalog':41 'chat':108,114,122,178,181,196,229,441,479,520,547,569,597,642 'chatfrag':462,504 'chatsfrag':645 'class':260,354,461,503 'code':78 'cometchat':2,9,25,34,49,90,138,148,156 'cometchat-android-v5-components':33,147 'cometchat-android-v5-core':24,137 'cometchat-android-v5-placement':1 'cometchat-android-v5-theming':155 'cometchat.callbacklistener':303,329,393,415 'cometchat.getgroup':326,412,725 'cometchat.getuser':300,390,722 'cometchatcalllog':677 'cometchatconvers':482,647 'cometchatexcept':320,346,409,431 'cometchatgroup':667 'cometchatmessagecompos':283,575,701 'cometchatmessagehead':275,703,737 'cometchatmessagelist':279,571,700 'cometchatus':657 'commit':687 'common':242 'communiti':201 'companion':22 'compon':37,40,144,151,699 'compos':284,376,576,604 'composer.setgroup':340,425 'composer.setuser':314,403,581,609 'construct':729 'contain':472,480,511,521,646,656,666,676,685 'context':186 'convers':483,489,524,530,623 'conversations.setonitemclick':486,527 'core':28,141 'cover':29,56 'custom':152 'd':616 'dashboard':191 'decid':96 'dedic':60,170,236 'default':742 'dialog':17,64,219 'dismiss':216 'e':321,347,408,430 'either':493,534,705 'els':322,648,658,668,678 'emb':440 'embed':20,67,222 'entri':766 'everi':760 'exampl':79 'exist':52,93,194,226,447 'experi':179 'extend':262,463 'fals':481,522,680 'featur':199 'fetch':713 'findviewbyid':277,281,285,369,373,377 'finish':351,435 'fragment':15,62,100,192,439,444,464,495,505,536,634,635,643,653,663,673,686 'full':176,246,620 'full-screen':175,245 'fun':358,395,406,417,428,507 'getint':289,294 'getlayoutinflat':565 'getstringextra':290,295 'getsupportfragmentmanag':681 'gone':744 'good':553 'group':334,335,337,339,341,419,420,422,424,426,625,662,696,716 'groupsfrag':665 'guid':293,296,324,327,384,386,410,413,726 'hard':690 'header':276,368 'header.setbackiconvisibility':348,432 'header.setgroup':336,421 'header.setonbackpress':350,434 'header.setuser':310,399 'helpdesk':210 'icon':734 'id':637,640,650,660,670 'includ':71 'inflat':470,509,566 'inflater.inflate':477,518 'init':30 'init/login':135 'inlin':228 'instruct':76 'int':636 'integr':89 'intent':164 'intent.getstringextra':381,385 'intrus':215 'item':633 'item.getitemid':638 'java':82,257,258,458,459,556,557,630,631 'kotlin':84,352,353,501,502,586,587 'layout':227,254,457 'layoutinflat':469,510 'layoutinflater.inflate':594 'lightweight':220 'login':32 'look':142 'manifest':765 'manual':731 'marketplac':180 'messag':168,251,274,366,492,533,698 'messagelist':280,372,572,600 'messagelist.setgroup':338,423 'messagelist.setuser':312,401,579,607 'messagesact':253,261,355 'messeng':208,621 'method':739 'modal':221 'multi':206,455 'multi-pan':454 'multi-sect':205 'navig':490,531,618,753 'need':751,763 'neither':712 'never':709,711 'new':183,302,328,560,644,654,664,674,761 'non':214 'non-intrus':213 'null':299,325,389,411,570,598 'object':392,414,717,730 'oncreat':267,359 'oncreateview':468,508 'onerror':319,345,407,429 'onsuccess':307,333,396,418 'overlay':212,552 'overrid':264,304,316,330,342,357,394,405,416,427,465,506 'pane':456 'pattern':21,59,70,234,243,437,543,615 'placement':5,58,161,166 'posit':488,529 'product':188 'project':54 'protect':265 'provid':38 'public':259,305,317,331,343,460,466 'purpos':42 'put':8,48,106 'quick':217 'r.id.composer':286,378,578,606 'r.id.conversations':485,526 'r.id.fragment':684 'r.id.header':278,370 'r.id.messagelist':282,374,574,602 'r.id.nav':641,651,661,671 'r.layout.activity':273,365 'r.layout.bottom':567,595 'r.layout.fragment':478,519 'recommend':162,165 'regist':755 'replac':494,535,683 'repli':218 'requir':704 'return':499,540,679,688 'rule':691 'saa':190,451 'savedinstancest':269,271,360,363,474,513 'screen':109,177,232,247 'section':207 'separ':185 'set':133,693,719,732,745 'setbackiconvis':741 'setcontentview':272,364 'setgroup':708 'setus':706 'sheet':126,551,568,596 'show':121,546 'simplest':239 'six':57 'skill':23,44,87,131 'skill-cometchat-android-v5-placement' 'social':200 'source-cometchat' 'start':497,538 'step':73,75 'step-by-step':72 'string':287,292 'super.oncreate':270,362 'support':209 'support/helpdesk':555 'tab':18,117,174,204,619,629 'tab/viewpager':65 'teach':45 'theme':159 'topic-agent-skills' 'topic-ai-agent' 'topic-chat' 'topic-claude-code' 'topic-cometchat' 'topic-cursor' 'topic-messaging' 'topic-nextjs' 'topic-react' 'topic-react-native' 'topic-ui-kit' 'true':689 'uid':288,291,298,301,380,382,388,391,723 'use':85,129,136,146,154,449,721 'user':163,308,309,311,313,315,397,398,400,402,404,580,582,608,610,624,652,694,715,750 'usersfrag':655 'v':487,528 'v5':4,27,36,140,150,158 'val':367,371,375,379,383,516,523,588,592,599,603 'view':68,224,252,467,475,476,500,515,517,541,563,564,584,593,612 'view.findviewbyid':484,525,573,577,601,605 'view.visible':349,433 'viewgroup':471,512 'viewpag':202 'visibl':735,747 'void':266,306,318,332,344 'vs':99,101 'widget':223 'within':230,445 'xml':256","prices":[{"id":"3c0a1fe7-181b-42a9-936c-f3eeb2fa3000","listingId":"62073500-104e-4b67-ac15-32d55a173b72","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"cometchat","category":"cometchat-skills","install_from":"skills.sh"},"createdAt":"2026-05-07T13:05:03.961Z"}],"sources":[{"listingId":"62073500-104e-4b67-ac15-32d55a173b72","source":"github","sourceId":"cometchat/cometchat-skills/cometchat-android-v5-placement","sourceUrl":"https://github.com/cometchat/cometchat-skills/tree/main/skills/cometchat-android-v5-placement","isPrimary":false,"firstSeenAt":"2026-05-07T13:05:03.961Z","lastSeenAt":"2026-05-18T19:04:45.108Z"}],"details":{"listingId":"62073500-104e-4b67-ac15-32d55a173b72","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"cometchat","slug":"cometchat-android-v5-placement","github":{"repo":"cometchat/cometchat-skills","stars":27,"topics":["agent-skills","ai-agent","chat","claude-code","cometchat","cursor","messaging","nextjs","react","react-native","ui-kit"],"license":null,"html_url":"https://github.com/cometchat/cometchat-skills","pushed_at":"2026-05-18T05:04:24Z","description":"Add CometChat chat to any React, Next.js, React Native, Angular, Android, iOS, or Flutter project through your AI coding agent. Works with Claude Code, Cursor, Codex, VS Code Copilot, Windsurf, Cline, Kiro, and 50+ more agents.","skill_md_sha":"efe4cc8796b844932626f62ffc8d00a15772c598","skill_md_path":"skills/cometchat-android-v5-placement/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/cometchat/cometchat-skills/tree/main/skills/cometchat-android-v5-placement"},"layout":"multi","source":"github","category":"cometchat-skills","frontmatter":{"name":"cometchat-android-v5-placement","license":"MIT","description":"Where to put CometChat in your Android app — Activity, Fragment, BottomSheet, Dialog, Tab, or embedded patterns.","compatibility":"Android 7.0+; Java 8+; Kotlin 1.8+; com.cometchat:chat-uikit-android:5.x"},"skills_sh_url":"https://skills.sh/cometchat/cometchat-skills/cometchat-android-v5-placement"},"updatedAt":"2026-05-18T19:04:45.108Z"}}