{"id":6763,"date":"2025-11-04T18:58:13","date_gmt":"2025-11-04T18:58:13","guid":{"rendered":"https:\/\/obsidiansofteducation.com\/?page_id=6763"},"modified":"2025-11-04T19:00:57","modified_gmt":"2025-11-04T19:00:57","slug":"app-inventor-extension-tutorial-how-to-make-a-custom-extension-in-mit-app-inventor-easiest-way","status":"publish","type":"page","link":"https:\/\/obsidiansofteducation.com\/index.php\/app-inventor-extension-tutorial-how-to-make-a-custom-extension-in-mit-app-inventor-easiest-way\/","title":{"rendered":"App Inventor Extension Tutorial &#8211; How to make a custom extension in MIT App Inventor &#8211; Easiest Way"},"content":{"rendered":"\n<p class=\"has-medium-font-size\">Hello friends, and welcome to Obsidian Soft,<\/p>\n\n\n\n<p class=\"has-medium-font-size\">In this tutorial, I\u2019ll show you how to create your own custom extension for MIT App Inventor \u2014 using Niotron IDE \u2014 completely online, with no software installation.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/snake-game-16-1024x576.jpg\" alt=\"\" class=\"wp-image-6768\" style=\"width:646px;height:auto\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/snake-game-16-1024x576.jpg 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/snake-game-16-300x169.jpg 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/snake-game-16-768x432.jpg 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/snake-game-16-800x450.jpg 800w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/snake-game-16.jpg 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"has-medium-font-size\">We\u2019ll create a fun and useful color picker extension that allows users to select from 12 different colors in a pop-up window. Let\u2019s have a look at the demo.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">You can see how useful this extension can be in your drawing or doodle apps.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">So, let&#8217;s begin.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Go to \ud83d\udc49 <a href=\"https:\/\/my.niotron.com\/\" target=\"_blank\" rel=\"noopener\">https:\/\/my.niotron.com\/<\/a> and sign in using your Google account.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Click on Extension IDE on the left. We\u2019re using Niotron\u2019s online IDE because it\u2019s the easiest and most beginner-friendly way to make extensions for MIT App Inventor or Niotron. We don\u2019t need to download or install anything, such as Git or Ant.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Start a new project. Name it ColorPicker. The package should have a name like this: <strong>com.yourname.projectname<\/strong>. So, I will name it <strong>com.obsidiansoft.colorpicker<\/strong>.&nbsp; Add a short description, and you can optionally give an icon here\u2026.but it has to be a URL.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">For this purpose, I downloaded a free color picker icon from&nbsp;<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><a href=\"https:\/\/www.flaticon.com\/free-icon\/color-picker_2867978\" target=\"_blank\" rel=\"noopener\">https:\/\/www.flaticon.com\/free-icon\/color-picker_2867978<\/a> (<strong>Special thanks to the color picker icon created by iconixar<\/strong>)<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Then, I uploaded it to Google Drive. I changed its sharing access to public by choosing anyone can see and then copied the link. And pasted it in Niotron IDE in the space for icon URL.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color has-link-color has-medium-font-size wp-elements-9c9ebbf0a45ab9844b943c2ca035f544\"><em>A disclaimer here: the icon URL doesn&#8217;t always work.<\/em><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Click on Continue button. You will soon see a sample extension generated for you on the left.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, this is Java. I know most of you are unfamiliar with Java. The great thing about the advent of AIs like ChatGPT is that you can ask it to write the extension for you. However, you still need to know a little bit to make changes. So, let\u2019s quickly go over this code.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"794\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/ApplicationFrameHost_2Gki6HMX3l-1-1024x794.png\" alt=\"\" class=\"wp-image-6765\" style=\"width:667px;height:auto\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/ApplicationFrameHost_2Gki6HMX3l-1-1024x794.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/ApplicationFrameHost_2Gki6HMX3l-1-300x233.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/ApplicationFrameHost_2Gki6HMX3l-1-768x595.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/ApplicationFrameHost_2Gki6HMX3l-1.png 1037w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\"><strong>package com.obsidiansoft.colorpicker;<\/strong> is just your project\u2019s address.<\/li>\n\n\n\n<li class=\"has-medium-font-size\">Those lines with <strong>import <\/strong>in front of them are like \u201ctools\u201d or \u201cingredients\u201d that the extension needs for accessing the phone\u2019s screen, app data, and for showing up in MIT App Inventor\u2019s designer and blocks section.<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>@DesignerComponent <\/strong>is how your extension looks in the designer section of MIT App Inventor.<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>@SimpleObject(external = true) <\/strong>means it\u2019s a <strong>simple object<\/strong> users can add blocks for.<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>@UsesPermissions(permissionNames = &#8220;&#8221;) <\/strong>specify any special permissions such as camera, internet here.<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>public class ColorPicker extends AndroidNonvisibleComponent {<\/strong> This is just telling that it is a component that doesn&#8217;t show up visibly and does its work in the background.<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>context <\/strong>helps access resources,<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>activity <\/strong>helps show things like dialogs or popups.<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>public ColorPicker(ComponentContainer container)<\/strong> is the constructor. This runs when the user adds your extension to their project. It connects your extension to the app\u2019s screen and environment.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-medium-font-size\">Till now, all extensions are almost identical. The difference comes when we come to part of simple functions and simple events.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\"><strong>Simple functions<\/strong>, such as TestFunction, generated here, will become a block in App Inventor<\/li>\n\n\n\n<li class=\"has-medium-font-size\"><strong>Simple events<\/strong>, such as TestEvent generated here, will become an event in App Inventor.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-medium-font-size\"><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, you can use ChatGPT to make your Java simple functions and events for you. But remember that your import statements will also change depending on what tools you use inside your function. For example, I need to show dialogs and buttons for my color picker, so you will see more import statements in the code that I will give to you.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">This is the code: you can copy paste it entirely too, but I would recommend changing your package name to your actual one \ud83d\ude09 and also not using the icon URL given in this code too as that is just a place holder.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.obsidiansoft.colorpicker;\n\nimport android.app.Activity;\nimport android.app.AlertDialog;\nimport android.content.Context;\nimport android.graphics.Color;\nimport android.view.View;\nimport android.widget.Button;\nimport android.widget.LinearLayout;\nimport android.widget.ScrollView;\nimport android.widget.Toast;\n\nimport com.google.appinventor.components.annotations.*;\nimport com.google.appinventor.components.common.ComponentCategory;\nimport com.google.appinventor.components.runtime.AndroidNonvisibleComponent;\nimport com.google.appinventor.components.runtime.ComponentContainer;\nimport com.google.appinventor.components.runtime.EventDispatcher;\n\n@DesignerComponent(\n        version = 1,\n        description = \"A simple extension for picking colors.\",\n        category = ComponentCategory.EXTENSION,\n        nonVisible = true,\n        iconName = \"https:\/\/i.postimg.cc\/XYZ\/color-picker.png\")\n\n@SimpleObject(external = true)\npublic class ColorPicker extends AndroidNonvisibleComponent {\n\n    private Context context;\n    private Activity activity;\n\n    public ColorPicker(ComponentContainer container) {\n        super(container.$form());\n        this.activity = container.$context();\n        this.context = container.$context();\n    }\n\n    @SimpleFunction(description = \"Show a simple color picker dialog.\")\n    public void ShowColorPicker() {\n\n        final int&#91;] colors = {\n                Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW,\n                Color.MAGENTA, Color.CYAN, Color.BLACK, Color.WHITE,\n                Color.GRAY, Color.DKGRAY, Color.LTGRAY, Color.parseColor(\"#FFA500\")\n        };\n\n        final String&#91;] colorNames = {\n                \"Red\", \"Green\", \"Blue\", \"Yellow\",\n                \"Magenta\", \"Cyan\", \"Black\", \"White\",\n                \"Gray\", \"Dark Gray\", \"Light Gray\", \"Orange\"\n        };\n\n        final AlertDialog dialog = new AlertDialog.Builder(context).create();\n\n        ScrollView scrollView = new ScrollView(context);\n        LinearLayout mainLayout = new LinearLayout(context);\n        mainLayout.setOrientation(LinearLayout.VERTICAL);\n        scrollView.addView(mainLayout);\n\n        for (int i = 0; i &lt; colors.length; i++) {\n            final int selectedColor = colors&#91;i];\n            final String selectedName = colorNames&#91;i];\n\n            Button btn = new Button(context);\n            btn.setText(selectedName);\n            btn.setBackgroundColor(selectedColor);\n            btn.setTextColor(i == 7 ? Color.BLACK : Color.WHITE);\n            btn.setPadding(10, 10, 10, 10);\n\n            btn.setOnClickListener(new View.OnClickListener() {\n                @Override\n                public void onClick(View v) {\n                    Toast.makeText(context, \"You picked: \" + selectedName, Toast.LENGTH_SHORT).show();\n                    GotColor(selectedColor);\n                    dialog.dismiss(); \n                }\n            });\n\n            mainLayout.addView(btn);\n        }\n\n        dialog.setTitle(\"Pick a Color\");\n        dialog.setView(scrollView);\n        dialog.show();\n    }\n\n    @SimpleEvent(description = \"Triggered when a color is chosen.\")\n    public void GotColor(int colorValue) {\n        EventDispatcher.dispatchEvent(this, \"GotColor\", colorValue);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">Click the save button at the top and then click the compile button. An AIX file for your extension should be successfully downloaded to your computer to, most probably, your downloads folder.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, let\u2019s test our new extension out.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Open up MIT App Inventor. Start a new project.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">In designer view, o to the Extensions section. It comes on the left towards the very bottom.  Click on Import Extension \u2192 Choose File \u2192 Upload your .aix file.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Drag your ColorPicker extension into the project workspace.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Add a button from the UserInterface palette. Rename it to pickColorBtn and change the text accordingly. Add a label for preview. I am just going to make its font size bigger.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">In the blocks section, get the button click event. Click on your custom extension, and you can see the simple function and event visibly here. Call the extension\u2019s showColorPicker in the button click event. And get the extension\u2019s GotColor Event, and here set the label\u2019s background color to the color returned by the event.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"130\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/image.png\" alt=\"\" class=\"wp-image-6766\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/image.png 642w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/image-300x61.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"950\" height=\"182\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/image-1.png\" alt=\"\" class=\"wp-image-6767\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/image-1.png 950w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/image-1-300x57.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/11\/image-1-768x147.png 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Too complicated process for you. No worries \ud83d\ude09 You can download the extension (aix) file from here:<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><a href=\"https:\/\/github.com\/amnaMahmoodObs\/ColorPickerExtension\/releases\/tag\/v1.0.0\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/amnaMahmoodObs\/ColorPickerExtension\/releases\/tag\/v1.0.0<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">I hope you liked this easy way of making extensions for MIT App Inventor or even Kodular.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">You can also check out the video tutorial for this project on my channel.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<p class=\"responsive-video-wrap clr\"><iframe loading=\"lazy\" title=\"App Inventor Extension | Easy Tutorial | How to Make a Color Picker Extension in MIT App Inventor \ud83c\udfa8\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/CDXtWnNCzVE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<\/div><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Please like my tutorials and share it with your friends and family. Also, subscribe to my channel and press the bell icon so you don\u2019t miss any of the great projects I have planned for you.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><a href=\"https:\/\/www.youtube.com\/c\/obsidiansofteducation\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/c\/obsidiansofteducation<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Please like my Facebook page and Instagram page for more educational resources and tips.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Facebook:<\/strong><a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.facebook.com\/ObsidianSoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Instagram:<\/strong><a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.instagram.com\/obsidiansoftapps\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Pinterest:<\/strong>&nbsp;<a href=\"https:\/\/www.pinterest.com\/obsidiansoft\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.pinterest.com\/obsidiansoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">For links to free educational&nbsp;<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/flappy-bird-game-mit-app-inventor\/#\">&nbsp;apps<\/a>, have a look at the&nbsp;<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/mobile-apps\/\">educational apps page<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends, and welcome to Obsidian Soft, In this tutorial, I\u2019ll show you how to create your own custom extension for MIT App Inventor \u2014 using Niotron IDE \u2014 completely online, with no software installation. We\u2019ll create a fun and useful color picker extension that allows users to select from 12 different colors in a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6763","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/comments?post=6763"}],"version-history":[{"count":2,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6763\/revisions"}],"predecessor-version":[{"id":6770,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6763\/revisions\/6770"}],"wp:attachment":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media?parent=6763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}