App Inventor: Vytvoření aplikace pro Android - kurz
V tomto praktickém tipu vysvětlíme, jak vytvářet aplikace pro Android pomocí aplikace Inventor. Postupujte podle tohoto návodu a vytvářejte aplikace v relativně krátkém čase.
Přihlaste se do aplikace MIT App Inventor
Přejděte na web App Inventor a klikněte na tlačítko Vytvořit v pravém horním rohu.
- Aplikace Inventor vyžaduje povolení přístupu k vašemu účtu Google. Potvrďte kliknutím na „Povolit“.
- Po prvním přihlášení se můžete zúčastnit průzkumu. Pokud si to nepřejete, klikněte na „Nikdy neužít průzkum“.
- Poté klikněte na „Pokračovat“ do pracovního prostoru aplikace Inventor.
Vytvořte první aplikaci v aplikaci Inventor - rozvržení
- V levém horním rohu klikněte na tlačítko Nový projekt. Zadejte název projektu a vyberte „Ok“.
- Nyní přetáhněte „štítek“ z „uživatelského rozhraní“ vlevo do obrazovky zobrazené uprostřed. V části „Vlastnosti“ můžete změnit „Text“ pro nově přidaný štítek.
- Uložte svůj projekt přes „Projekt“ a vyberte „Uložit projekt“.
- Nyní můžete na obrazovku posunout všechny ostatní prvky uživatelského rozhraní. Další mediální obsah lze také přidat pomocí „Kreslení a animace“.
- Pomocí rozložení změňte uspořádání prvků.
Logika nad bloky - příklad
Pokud chcete pro svoji aplikaci vytvořit další obrazovky, klikněte na „Přidat obrazovku“. Poté můžete přejít na druhou obrazovku ve vašem rozvržení, například pomocí prvku UI „Tlačítko“. K tomu však potřebujete logiku běžící na pozadí. V App Inventoru je sestavujete pomocí „Bloků“.
- Chcete-li to provést, klikněte na "Bloky" vedle "Návrhář" v pravém horním rohu. Tam přejdete na příslušnou obrazovku a kliknete na tlačítko na levém displeji „Bloky“.
- Vyberte funkci "když Button1.Click do".
- Nyní do tohoto prvku „Puzzle“ vložte prvek „Control“, konkrétně „otevřete jinou obrazovku screenName“.
- Nyní chybí pouze jméno obrazovky. Klikněte na "Text" na obrazovce Bloky a vyberte horní prvek, který se skládá pouze ze dvou uvozovek.
- Do tohoto textového prvku, v tomto příkladu „Screen2“, zadejte název obrazovky.
Vyzkoušejte aplikaci na smartphonu
Pokud chcete vyzkoušet své aplikace vytvořené v App Inventor přímo na smartphonu Android, postupujte podle níže uvedených kroků.
- Nainstalujte do svého smartphonu Android aplikaci MIT App Inventor Companion.
- Zkontrolujte, zda jsou váš počítač a smartphone s Androidem ve stejné síti WiFi.
- Spusťte aplikaci na svém smartphonu a klikněte na "Připojit" v horním panelu nabídek na vašem PC a vyberte "AI Companion".
- Klepněte na „naskenovat QR kód“ v aplikaci na vašem smartphonu a naskenujte QR kód zobrazený na vašem PC. Nebo zadejte 6místný kód zobrazený v textovém poli aplikace a klepněte na tlačítko „Připojit s kódem“.
- Tuto aplikaci si nyní můžete vyzkoušet na svém Smarpthone.
Otestujte aplikaci pomocí emulátoru
Pokud nemáte smartphone k dispozici, vyzkoušejte aplikaci na emulátoru integrovaném do aplikace Inventor.
- Stáhněte si a nainstalujte software App Inventor.
- Nyní otevřete nainstalovanou aplikaci. Na vašem počítači se otevře obrazovka mobilního telefonu.
- Nyní klikněte na "Připojit" na liště nabídky App-Inventor pod otevřeným projektem a vyberte tam "Emulátor". Možná jste museli klepnout na „Obnovit připojení“, pokud jste byli dříve připojeni k smartphonu.
- Aplikace se nyní zobrazí v emulátoru.
- V některých případech se zobrazí chybová zpráva. Aplikace Companion proto již není aktuální. V zobrazeném okně klikněte na „OK“.
- Potvrďte aktualizaci v emulátoru pomocí „OK“ a „Instalovat“. Nakonec na obrazovce emulátoru klikněte na „Hotovo“.
- Připojte se znovu přes „Připojit“ -> „Obnovit připojení“ a poté „Připojit“ -> „Emulátor“.
Po vytvoření aplikace můžete uložit soubor .apk aplikace do svého počítače na liště nabídek pomocí "Sestavit". Jakmile aplikaci zveřejníte na Google Play, měli byste také přemýšlet o marketingu své aplikace.