Androidéçºã¯è€éã«æããããã¡ã§ãããæ£ããåºç€ç¥èãšããŒã«ã§å¹ççã«åŠã³å§ããããŸãããã®èšäºã§ã¯ãããžãã¹ããŒãœã³ã察象ã«ãããã10åã§Androidã¢ããªéçºã®åºæ¬ãJavaèšèªã§è§£èª¬ããŸããç§ãã¡ã¯éçºç°å¢ã®ã»ããã¢ããããå§ããŠãã¢ããªã®ç»é¢ã§ããã¢ã¯ãã£ããã£ã®æ§ç¯ããããŠç°å¢æ§ç¯ãUIãã¶ã€ã³ãAPIã®æŽ»çšã«è³ããŸã§ãã«ããŒããæçµçã«ã¯å®äŸãéããéçºæè¡ãŸã§ã玹ä»ããŸãããã®çããªãŒãã§ããªãã®Androidéçºæ è¡ãã¹ã¿ãŒãããããžãã¹ã«ããã競äºåãé«ããããã®ã¹ãã«ãæã«å ¥ããŸãããã
1. Androidéçºã®åºç€æŠèŠ
Androidéçºãšã¯ãäžçã§æãæ®åããŠããã¹ããŒããã©ã³OSã§ããAndroidäžã§åäœããã¢ããªã±ãŒã·ã§ã³ãäœæããããã»ã¹ã§ããããæ°å¹Žã§ã¹ããŒããã©ã³ã®äœ¿çšãççºçã«å¢å ãããããAndroidã¢ããªéçºè ãžã®éèŠãé«ãŸã£ãŠããŸãããã®èšäºã§ã¯ãåããŠAndroidã¢ããªéçºãåŠã¶æ¹åãã«ã10åã§åºç€ãææ¡ã§ããããç°¡æœã«è§£èª¬ããŸãã
1.1 Androidãã©ãããã©ãŒã ãšã¯ïŒ
Androidãã©ãããã©ãŒã ã¯ãGoogleãéçºãããªãŒãã³ãœãŒã¹ã®ã¢ãã€ã«ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§ãããã®ãã©ãããã©ãŒã ã®ç¹åŸŽã¯ãæ§ã ãªã¡ãŒã«ãŒã®ããã€ã¹ã§æè»ã«åäœããç¹ããèšå€§ãªã¢ããªã±ãŒã·ã§ã³åžå Žãžã®ã¢ã¯ã»ã¹ãå¯èœãªç¹ã«ãããŸããAndroidã¢ããªã¯äž»ã«Javaèšèªã§èšè¿°ãããŠãããKotlinãšããèšèªãå ¬åŒã«ãµããŒããããŠããŸãã
Androidã®ã¢ãŒããã¯ãã£ãŒã¯è€æ°ã®ã¬ã€ã€ãŒããæãç«ã£ãŠãããLinux ã«ãŒãã«ãäžå±€ã«ããããšã§ã»ãã¥ãªãã£ãã¡ã¢ãªç®¡çãªã©ãå¹ççã«è¡ãããšãã§ããŸããäžå±€ã§ã¯ã¢ããªã±ãŒã·ã§ã³ãã¬ãŒã ã¯ãŒã¯ãéããŠéçºè ã容æã«ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ã§ããããã«ãªã£ãŠããŸãã
ãã®ãã©ãããã©ãŒã ã«ã¯Google PlayãšåŒã°ããã¢ããªã¹ãã¢ãããããããéããŠã¢ããªãäžçäžã§é åžãããŸããã¢ããªéçºè ã¯ãç°ãªãã¹ã¯ãªãŒã³ãµã€ãºãèšèªãããŒããŠã§ã¢æ©èœãªã©ããµããŒãããããã«ãæè»ã«å¯Ÿå¿ããå¿ èŠããããŸãã
1.2 Androidã¢ããªéçºã®æµã
Androidã¢ããªã±ãŒã·ã§ã³ã®éçºæµãã¯ãèŠä»¶å®çŸ©ããå§ãŸããèšèšãå®è£ ããã¹ãããããŠãªãªãŒã¹ãšããäžé£ã®ã¹ãããã«åãããŠããŸããéçºè ã¯æåã«ãã¢ããªã®ç®çãã¿ãŒã²ãããŠãŒã¶ãŒãæ確ã«ãããã®äžã§æ©èœèŠä»¶ãå®ããŸãã
èšèšæ®µéã§ã¯ããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ã®ã¬ã€ã¢ãŠããã¢ããªã®æ§é ã決å®ããŸããå®è£ ã§ã¯Javaã䜿çšããŠãèšèšãããUIãšããžãã¯ãã³ãŒãã«å€æããŸãããããŠããšãã¥ã¬ãŒã¿ãå®æ©ã§ã®ãã¹ããçµãŠãæé©åãšãã°ä¿®æ£ãè¡ããGoogle PlayãéããŠã¢ããªããªãªãŒã¹ããŸãã
ãªãªãŒã¹åŸã®ã¢ããªã¯ããã£ãŒãããã¯ããŠãŒã¶ãŒã®äœ¿çšç¶æ³ãåæããªãããã¢ããããŒããæ©èœã®è¿œå ãè¡ãããšãäžè¬çã§ããããŒã±ããã®ããŒãºãæè¡ã®é²æ©ã«å¿ããŠã¢ããªãé²åããããŠãŒã¶ãŒã«ãšã£ãŠäŸ¡å€ã®ãããã®ã«ä¿ã€ããšãéçºè ã®éèŠãªåœ¹å²ãšãªããŸãã
1.3 éçºç°å¢ã®ã»ããã¢ãã
Androidã¢ããªã±ãŒã·ã§ã³ã®éçºã«ã¯ãéçºç°å¢ã®ã»ããã¢ãããå¿ é ã§ããæãäžè¬çãªéçºç°å¢ã¯Android StudioãšãããŠãããGoogleããæäŸãããŠããå ¬åŒã®çµ±åéçºç°å¢ïŒIDEïŒã§ãã
Android Studioã®ã»ããã¢ããã¯æ¯èŒççŽæçã§ãGoogleã®æäŸããå ¬åŒãµã€ãããã€ã³ã¹ããŒã©ãããŠã³ããŒãããŠå®è¡ããããšã§å®äºããŸããAndroid Studioã䜿çšããããšã§ãã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒãã£ã³ã°ããããã°ãããã³ãã¹ããè¡ããããã«ãªããŸãã
ãŸããAndroid Virtual Device (AVD) ãããŒãžã£ã䜿çšããããšã§ãããŸããŸãªããã€ã¹ãšAndroidã®ããŒãžã§ã³ã§ã¢ããªãã·ãã¥ã¬ãŒãããå®æ©ããªããŠãã¢ããªã®æåã確èªããããšãã§ããŸããå¿ èŠãªSDKã³ã³ããŒãã³ãã¯ãAndroid Studioå ããããŠã³ããŒããšæŽæ°ãè¡ãããšãã§ããŸãã
1.4 å¿ èŠãªããŒã«ãšSDKã®ç解
Androidã¢ããªéçºã«ã¯ãSoftware Development Kit (SDK) ã®ç解ãäžå¯æ¬ ã§ããSDKã«ã¯ãAndroidã¢ããªãéçºããããã«å¿ èŠãªã©ã€ãã©ãªãããŒã«ãå«ãŸããŠãããå®è³ªçã«ãããã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããŸãã
SDKããŒã«ã«ã¯ãã³ãŒããã³ã³ãã€ã«ããŠAPKãšããããã±ãŒãžãã¡ã€ã«ãçæããããã®ãã«ãããŒã«ããããŒãžã§ã³ããšã®APIãå¿ èŠãªãšãã¥ã¬ãŒã¿ã€ã¡ãŒãžãªã©ãå«ãŸããŠããŸããéçºè ã¯ã䜿çšããAndroidã®ããŒãžã§ã³ã«å¿ããŠé©åãªAPIã¬ãã«ã®SDKãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã
ããã«ãAndroid Studioã§ã¯ãã©ã°ã€ã³ãè¿œå ããŒã«ãå°å ¥ããããšã§ãã¬ã€ã¢ãŠããšãã£ã¿ãŒãããŒãžã§ã³ç®¡çã·ã¹ãã ãããã©ãŒãã³ã¹ã¢ãã¿ãªã³ã°ããŒã«ãªã©ãéçºã®çç£æ§ãåäžãããããšãã§ããŸãããããã®ããŒã«ãããŸãå©çšããããšã§ãå¹ççãã€é«å質ãªã¢ããªã®éçºãå¯èœãšãªããŸãã
2. Javaã䜿ã£ãAndroidã¢ããªã®æ§æèŠçŽ
Javaèšèªã¯ãAndroidã¢ããªéçºã«ãããéèŠãªåœ¹å²ãæãããŸããããã¯ãAndroidç¹æã®æ§æèŠçŽ ãšå¯æ¥ã«é£æºããŠã·ã¹ãã äžã§åäœããå€æ§ãªã¢ããªã±ãŒã·ã§ã³ãå®çŸããããã§ãã以äžã«ãJavaã䜿ã£ãAndroidã¢ããªã®åºæ¬çãªæ§æèŠçŽ ã«ã€ããŠè§£èª¬ããŸãã
2.1 ã¢ã¯ãã£ããã£ãšã¯ – Androidã¢ããªã®ç»é¢
ã¢ã¯ãã£ããã£ãšã¯ãAndroidã¢ããªã®äžç»é¢ãåžãã³ã³ããŒãã³ãã§ãããŠãŒã¶ãŒãçŽæ¥ã€ã³ã¿ã©ã¯ã·ã§ã³ãè¡ãã€ã³ã¿ãŒãã§ã€ã¹ã§ãããã¢ããªéçºã«ãããŠäžå¿çãªåœ¹å²ãæãããŸããåã¢ã¯ãã£ããã£ã¯ç¬ç«ããŠãããã¢ããªã±ãŒã·ã§ã³ã®ç°ãªãæ©èœããã¥ãŒã衚瀺ããããã«äœ¿çšãããŸãã
Javaã§ã¢ã¯ãã£ããã£ãäœæããéã«ã¯ãAndroidã®ãã¬ãŒã ã¯ãŒã¯ããæäŸãããŠããActivityã¯ã©ã¹ãç¶æ¿ããŸããéçºè ã¯ãã®ã¯ã©ã¹ãæ¡åŒµããŠãã©ã€ããµã€ã¯ã«ã®ã³ãŒã«ããã¯ã¡ãœããããªãŒããŒã©ã€ãããããšã§ã¢ããªã®ç¶æ ã管çãããŠãŒã¶ãŒã®å ¥åã«å¿ããåŠçãè¡ããŸãã
ã¢ã¯ãã£ããã£éã®é·ç§»ã¯ã€ã³ãã³ããšããã¡ã«ããºã ãå©çšããŠè¡ããããŠãŒã¶ãŒã«ã¹ã ãŒãºãªããã²ãŒã·ã§ã³äœéšãæäŸããŸããããã«ãããè€æ°ã®ç»é¢ãæã€ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããããšãã§ããã®ã§ãã
2.2 ãµãŒãã¹ãšãããŒããã£ã¹ãã¬ã·ãŒããŒ
ãµãŒãã¹ã¯ãããã¯ã°ã©ãŠã³ãã§è¡ãããé·æéã®åŠçããã¢ã¯ãã£ããã£ã«äŸåããªãæäœãè¡ãããã®ã³ã³ããŒãã³ãã§ããã¢ããªã®åé¢ã«ãªãéããé³æ¥œåçããã¡ã€ã«ããŠã³ããŒãããããã¯ãŒã¯ãã©ã³ã¶ã¯ã·ã§ã³ãªã©ã®åŠçãç¶ç¶ããããšãå¯èœã§ãã
ãããŒããã£ã¹ãã¬ã·ãŒããŒã¯ãAndroidãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ããéãããŠããæ§ã ãªã€ãã³ããã€ã³ãã³ãã«åå¿ããããã®ã³ã³ããŒãã³ãã§ããããšãã°ãããããªãŒã®äœäžãç»é¢ã®ãªã³/ãªããæéã®çµéãªã©ã®ã·ã¹ãã ã€ãã³ãããã£ããããããã«å¿ããåŠçãè¡ãããšãã§ããŸãã
ãããã®ã³ã³ããŒãã³ãã¯ãJavaã³ãŒããçšããŠå®çŸ©ããã¢ããªã±ãŒã·ã§ã³ã«çµã¿èŸŒãããšã§ãããæŽç·Žãããæ©èœãæäŸããããšãã§ããŸããã¢ã¯ãã£ããã£ããŠãŒã¶ãŒãšçŽæ¥å¯Ÿè©±ããã®ã«å¯ŸããŠããµãŒãã¹ãšãããŒããã£ã¹ãã¬ã·ãŒããŒã¯ããã¯ã°ã©ãŠã³ãã§ã·ã¹ãã å šäœã®ã€ãã³ãã管çããŸãã
2.3 ã³ã³ãã³ããããã€ããŒãšã€ã³ãã³ã
ã³ã³ãã³ããããã€ããŒã¯ãæ§ã ãªã¢ããªã±ãŒã·ã§ã³éã§ããŒã¿ã®å ±æãå¯èœã«ããã³ã³ããŒãã³ãã§ããç°ãªãã¢ããªéã§ããŒã¿ãå ±æããããèªã¿èŸŒã¿ã»æžã蟌ã¿ãè¡ãããã®çµ±äžãããã€ã³ã¿ãŒãã§ã€ã¹ãæäŸããŸããããã«ããããŠãŒã¶ãŒã¯ã·ãŒã ã¬ã¹ã«æ å ±ã®äº€æãè¡ããããã«ãªããŸãã
äžæ¹ãã€ã³ãã³ãã¯ã¢ããªã±ãŒã·ã§ã³éã®ã³ãã¥ãã±ãŒã·ã§ã³ããã³ããªã³ã°ããããã®ã¡ãã»ãŒãžãªããžã§ã¯ãã§ããã¢ã¯ãã£ããã£ããµãŒãã¹ããããŒããã£ã¹ãã¬ã·ãŒããŒéã§ã®ããŒã¿ã®åãæž¡ãããæ©èœã®èµ·åãè¡ãããšãã§ããŸããã€ã³ãã³ãã䜿ã£ãŠãæ§ã ãªã¢ããªæ©èœãçµ±åãããŠãŒã¶ãŒã«äžè²«æ§ã®ããäœéšãæäŸããããšãã§ããŸãã
Javaã䜿çšããŠãããã®ã³ã³ããŒãã³ããå¹æçã«æ±ãã匷åãªã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœãšãªããŸããããŒã¿ã®ä¿è·ããã©ã€ãã·ãŒã«é¢ããèæ ®ãè¡ããªããããŠãŒã¶ãŒããªãã£ãšæ©èœæ§ãåäžããŸãã
2.4 ãããã§ã¹ããã¡ã€ã«ã®åœ¹å²
ã¢ã³ããã€ãã¢ããªã±ãŒã·ã§ã³ã®ãããã§ã¹ããã¡ã€ã«ïŒAndroidManifest.xmlïŒã¯ãã¢ããªã±ãŒã·ã§ã³å šäœã®æ§æãå®çŸ©ãããéåžžã«éèŠãªãã¡ã€ã«ã§ãããã®ãã¡ã€ã«ã«ã¯ã¢ããªã±ãŒã·ã§ã³ã®ååãã¢ã€ã³ã³ã䜿çšããã³ã³ããŒãã³ãïŒã¢ã¯ãã£ããã£ããµãŒãã¹ããããŒããã£ã¹ãã¬ã·ãŒããŒãã³ã³ãã³ããããã€ããŒïŒãªã©ã®æ å ±ãèšèŒãããŠããŸãã
ãŸãããããã§ã¹ããã¡ã€ã«ã«ã¯ãã¢ããªã±ãŒã·ã§ã³ãå¿ èŠãšããæš©éããã¢ããªã±ãŒã·ã§ã³ã®ãããã APIã¬ãã«ãä»ã®ã¢ããªã±ãŒã·ã§ã³ãšå ±æããã³ã³ããŒãã³ãã«é¢ããæ å ±ãå«ãŸããŠããŸããããã«ãããã¢ããªã®ã»ãã¥ãªãã£ãä¿ã¡ã€ã€ãäºææ§ãšäºæããªãåäœãé²æ¢ãã圹å²ãæãããŸãã
éçºè ã¯ãããã§ã¹ããã¡ã€ã«ãé©åã«èšå®ããã¢ããªã±ãŒã·ã§ã³ãæ£ããæ©èœããããã®åºç€ãäœããŸããJavaãšãšãã«ããããã®æ å ±ã掻çšããŠãæ©èœè±ãã§ãŠãŒã¶ãŒãã¬ã³ããªãŒãªã¢ããªã±ãŒã·ã§ã³ãéçºã§ããããã«ãªãããã§ãã
3. ç°å¢æ§ç¯ïŒAndroid StudioãšJavaã®ã»ããã¢ãã
ã¢ããªéçºãå§ããããã®ç¬¬äžæ©ã¯éçºç°å¢ãæŽããããšã§ããAndroidã®ã¢ããªãJavaã§éçºããã«ã¯ãGoogleãæäŸããçµ±åéçºç°å¢(IDE)ã§ããAndroid Studioãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã
Android Studioã¯ããããžã§ã¯ãã®ç®¡çãã³ãŒãã®ç·šéããããã°ããŒã«ããšãã¥ã¬ãŒã¿ãŒã§ã®ã¢ããªãã¹ããšãã£ããAndroidã¢ããªéçºã«å¿ èŠãªæ©èœãäžæã«æ ã£ãŠããŸãããã®ããŒã«ã¯å®æçãªã¢ããããŒããæœãããŠãããå®å®ããéçºç°å¢ãç¡æã§æäŸããŠããŸãã
Javaã®ã»ããã¢ããããŸãéèŠã§ãããAndroid Studioã®ã€ã³ã¹ããŒã«æã«ã¯èªåçã«é©åãªJava Development Kit (JDK)ãã»ããã¢ããããããããåå¿è ã§ã容æã«éå§ã§ããŸãã
3.1 Android Studioã€ã³ã¹ããŒã«æé
ãŸãã¯å ¬åŒãŠã§ããµã€ãã«ã¢ã¯ã»ã¹ããã䜿ãã®OSã«åãããAndroid StudioãããŠã³ããŒãããŸããã€ã³ã¹ããŒã©ãŒã®æ瀺ã«åŸãã€ã³ã¹ããŒã«ãé²ããå¿ èŠãªã³ã³ããŒãã³ãã®ããŠã³ããŒããçµããã°ã€ã³ã¹ããŒã«å®äºã§ãã
ã³ã³ããŒãã³ãã«ã¯ãAndroid SDKãé¢é£ãããã©ãããã©ãŒã ããŒã«ããšãã¥ã¬ãŒã¿ãŒã€ã¡ãŒãžãªã©ãå«ãŸããããšãå€ãããããã¯Androidã¢ããªéçºã«å¿ é ã§ããååèµ·åæã«é©å®ããŠã³ããŒãããããšãå¯èœã§ãã
ã€ã³ã¹ããŒã«åŠçã«ã¯å°ãæéããããããšããããŸãããå®äºããã°éçºãã¹ã¿ãŒãã§ããŸããã€ã³ã¹ããŒã«ãå®äºãããåæèšå®ãè¡ããã奜ã¿ã«åãããŠå€èŠãåäœãã«ã¹ã¿ãã€ãºããŸãããã
3.2 ãããžã§ã¯ãã®æ°èŠäœæãšèšå®
Android Studioãèµ·åããåŸãæ°èŠãããžã§ã¯ããäœæããŸãããStart a new Android Studio projectããéžæãããããžã§ã¯ãã®ååãä¿åå ãæå®ããŸããããã«ã䜿çšããããã°ã©ãã³ã°èšèªïŒJavaïŒãšæå°éãµããŒãããAndroidã®ããŒãžã§ã³ãéžæããŸãã
Android Studioã«ã¯å€ãã®ãã³ãã¬ãŒããçšæãããŠããããããžã§ã¯ãã®ç®çã«å¿ããŠæé©ãªãã®ãéžã¶ããšãã§ããŸããåå¿è ã«ãåãããããããã«ãã·ã³ãã«ãªãEmpty Activityããéžæãããšè¯ãã§ãããã
èšå®ãçµããããããžã§ã¯ããçæãããåºæ¬çãªãã¡ã€ã«æ§æãšãšãã«IDEäžã«è¡šç€ºãããŸããããã§ãããžã§ã¯ãã®èšå®ã¯å®äºããã³ãŒãã£ã³ã°ãå§ããæºåãæŽããŸãã
3.3 Androidãšãã¥ã¬ãŒã¿ãŒã®äœ¿ãæ¹
ç©ççãªããã€ã¹ããªããŠãã¢ããªã®åäœã確èªããããã®äŸ¿å©ãªããŒã«ãAndroidãšãã¥ã¬ãŒã¿ãŒã§ããç»é¢äžã«ä»®æ³ããã€ã¹ã衚瀺ããå®æ©ããããã®ããã«æäœããŠãããã°ãè¡ãããšãã§ããŸãã
ãšãã¥ã¬ãŒã¿ãŒãèšå®ããã«ã¯ãAndroid Studioã®ãAVD ManagerïŒAndroid Virtual Device ManagerïŒããéãããCreate Virtual DeviceããéžæããŠé©åœãªããã€ã¹ãéžã³ãŸãããã®åŸãå¿ èŠãªã·ã¹ãã ã€ã¡ãŒãžãããŠã³ããŒãããå¿ èŠãªèšå®ïŒCPU/ABIã解å床ãã¡ã¢ãªãŒãªã©ïŒãè¡ããŸãã
èšå®ãå®äºãããããLaunchããã¿ã³ãã¯ãªãã¯ããŠãšãã¥ã¬ãŒã¿ãŒãèµ·åããŸããããã§ã¢ããªã®ãã«ããåäœãã¹ããè¡ãªãããšãã§ããŸããé«ãæè»æ§ãšå©äŸ¿æ§ãèªããšãã¥ã¬ãŒã¿ãŒã¯ãéçºéçšã«ãããŠå€§ããªå©ãã«ãªããŸãã
3.4 ããã€ã¹ãžã®ã¢ããªã€ã³ã¹ããŒã«
æçµçãªãã¹ããšããŠãéçºäžã®ã¢ããªãå®éã®ããã€ã¹ã«ã€ã³ã¹ããŒã«ããããšãéèŠã§ãããŸããAndroidããã€ã¹ã®ãèšå®ãã¡ãã¥ãŒãããéçºè åããªãã·ã§ã³ããæå¹ã«ãããUSBãããã°ãããªã³ã«èšå®ããŸãã
次ã«ãããã€ã¹ãUSBã±ãŒãã«ã§ã³ã³ãã¥ãŒã¿ãŒã«æ¥ç¶ããŸããAndroid Studioãããã€ã¹ãèªèãããããRunããã¿ã³ãã¯ãªãã¯ããŠã¢ããªããã«ãããæ¥ç¶ããããã€ã¹ã«ã€ã³ã¹ããŒã«ããŸãããã®æãé©åãªããã€ã¹ãéžæãããŠããããšã確èªããŠãã ããã
ã¢ããªãããã€ã¹ã«ã€ã³ã¹ããŒã«ãããããå®æ©ã§ã®æäœæãããã©ãŒãã³ã¹ã®ç¢ºèªãå¯èœã§ããããã«ãããæçµçãªãã°ã®çºèŠããŠãŒã¶ãŒã®äœéšãåäžãããããã®æ¹åç¹ãèŠã€ããããšãã§ããŸãã
4. åããŠã®Androidã¢ããªïŒJavaãçšããã³ãŒãã£ã³ã°
Androidã¢ããªã±ãŒã·ã§ã³ã®éçºã¯ãæŠå¿µç解ããå®éã®ã³ãŒãã£ã³ã°ãŸã§æ°å€ãã®æ®µéããããŸãããŸãã¯ãJavaã䜿ã£ãŠã·ã³ãã«ãªã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããæ¹æ³ããå§ããŸããããJavaã¯Androidã¢ããªéçºã®ããã®äž»èŠãªããã°ã©ãã³ã°èšèªã®äžã€ã§ãã
Android StudioãããŠã³ããŒãããã€ã³ã¹ããŒã«ããåŸãæ°ãããããžã§ã¯ããå§ããæãåºæ¬çãªãã³ãã¬ãŒããçšæãããŠããŸãããEmpty Activityããéžæããããšã§ãæåã®ã¢ããªéçºãã¹ã ãŒãºã«å§ããããšãã§ããŸãã
ãããžã§ã¯ããéå§ããããæ§ã ãªã³ã³ããŒãã³ããšãã®æ©èœãèŠãŠããããšãéèŠã§ããã¢ã¯ãã£ããã£ããã¥ãŒãã€ã³ãã³ããšãã£ãåºæ¬çãªã³ã³ããŒãã³ãã®ç解ãã¢ããªéçºãé²ããäžã§å¿ èŠäžå¯æ¬ ã§ãã
4.1 Hello Worldã¢ããªã®æ§ç¯
Androidéçºã«ãããæåã®ãã€ã«ã¹ããŒã³ã¯ãå®çªã®ãHello Worldãã¢ããªãäœãããšã§ãããHello Worldãã¢ããªã¯éåžžã«ã·ã³ãã«ã§ãã¹ã¯ãªãŒã³äžã«ããã¹ãã衚瀺ããã ãã®ãã®ã§ãããã¢ããªã±ãŒã·ã§ã³ã®åºæ¬æ§é ãç解ããããã«ã¯æé©ã§ãã
æ°ãããããžã§ã¯ããäœæããããäž»èŠãªãã¡ã€ã«ã§ããMainActivity.javaã«æ³šç®ããŸãããããããã¢ããªã®æåãå¶åŸ¡ããã³ã¢ãšãªããŸããJavaã§æžããããã®ãã¡ã€ã«ã«ã¯ã¢ããªã®ã©ã€ããµã€ã¯ã«ãåžãã¡ãœãããå«ãŸããŠããŸãã
ãŸããã¬ã€ã¢ãŠãXMLãã¡ã€ã«ã§ã¯ããŠãŒã¶ãŒã€ã³ã¿ãã§ãŒã¹ã®èšèšãè¡ããŸãããTextViewããé 眮ãããHello, World!ããšããããã¹ãã衚瀺ãããããã«èšå®ããŸããããå®è¡ãããšããšãã¥ã¬ãŒã¿ãŒäžãŸãã¯æ¥ç¶ããããã€ã¹äžã§ã¢ããªãèµ·åããç»é¢ã«ããã¹ãã衚瀺ãããŸãã
4.2 ã¬ã€ã¢ãŠãã®èšèšïŒXMLãšJavaã®é£æº
Androidã¢ããªã«ãããŠãã¬ã€ã¢ãŠãã¯XMLãã¡ã€ã«ã§å®çŸ©ãããŸãããã®XMLãã¡ã€ã«ã¯ããžã¥ã¢ã«ãªéšåãæ§ç¯ããããŸããŸãªã³ã³ããŒãã³ããé 眮ããŸããã¬ã€ã¢ãŠããã¡ã€ã«ã¯res/layoutãã£ã¬ã¯ããªã«ä¿åãããããšãäžè¬çã§ãã
Javaã³ãŒããšã¬ã€ã¢ãŠãXMLã¯ç·å¯ã«é£æºããŠããŸããã¬ã€ã¢ãŠãXMLã§å®çŸ©ãããã¥ãŒã³ã³ããŒãã³ãïŒãã¿ã³ãããã¹ããã¥ãŒãªã©ïŒãJavaã³ãŒãã§æäœããããã«ã¯ããã¥ãŒãªããžã§ã¯ããååŸããå¿ èŠããããŸããäŸãã°ãfindViewById(R.id.myButton)ãšããã¡ãœããã䜿ã£ãŠãã¿ã³ãJavaã³ãŒãäžã§åç §ããããšãã§ããŸãã
ã¬ã€ã¢ãŠãXMLã§èšèšããã€ã³ã¿ãŒãã§ãŒã¹ãã¢ããªã®ããžãã¯ãšé¢é£ä»ããããšãã§ãããšããããã€ãããã¯ã§ã€ã³ã¿ã©ã¯ãã£ããªã¢ããªã±ãŒã·ã§ã³ãå®çŸã§ããŸãããOnClickããªã¹ããŒããã¿ã³ã«èšå®ãããªã©ããŠãŒã¶ãŒã®ã¢ã¯ã·ã§ã³ã«åå¿ããã€ãã³ããäœæããããšãå¯èœã§ãã
4.3 ã€ãã³ããã³ããªã³ã°ã®åºæ¬
ã¢ããªã±ãŒã·ã§ã³ã«ãããã€ãã³ããã³ããªã³ã°ã¯ããŠãŒã¶ãŒã®å ¥åãã¢ã¯ã·ã§ã³ã«ã¢ããªãã©ã®ããã«åå¿ããããå®ããéèŠãªéšåã§ããã€ãã³ãã¯ãŠãŒã¶ãŒããã¿ã³ãã¿ããããããã¹ã¯ãªãŒã³ãã¹ã¯ã€ããããããè¡çºã§ãã
ã€ãã³ããæ±ãã«ã¯ã察象ã®ãã¥ãŒïŒäŸãã°ãã¿ã³ïŒã«ãªã¹ããŒãèšå®ããŸããç°¡åãªäŸãšããŠã¯ããã¿ã³ã«setOnClickListenerã¡ãœããã䜿ã£ãŠæ°ããOnClickListenerãèšå®ããããšãæããããŸãããã®ãªã¹ããŒã¯ãã¿ã³ãæŒãããæã«å®è¡ããã¢ã¯ã·ã§ã³ãå®çŸ©ããŸãã
ãã®ã€ãã³ããã³ããªã³ã°ã®æŠå¿µãç解ããæ£ããå®è£ ããããšã§ãã¢ããªããŠãŒã¶ãŒã®æå³ããéãã«åäœããããã«ãªããŸããæè»ãªãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ãå®çŸããå¿«é©ãªæäœæãæäŸããããšãã§ããããã«ãªãã§ãããã
4.4 ãããã°æ¹æ³ã®æŠèŠ
ã¢ããªã±ãŒã·ã§ã³éçºã«ãããŠããããã°ã¯å¿ é ã®ã¹ãããã§ãããããã°ã«ãããã³ãŒãå ã®ãã°ãç¹å®ããä¿®æ£ããããšãã§ããŸããAndroid Studioã«ã¯åŒ·åãªãããã°ããŒã«ãåãã£ãŠãããéçºè ãå¹ççã«åé¡ã解決ã§ããããã«ããŠããŸãã
ãããã°ãéå§ããéã«ã¯ããã¬ãŒã¯ãã€ã³ããèšå®ããããšãã§ããŸãããã¬ãŒã¯ãã€ã³ãã¯ããã°ã©ã ã®å®è¡ãäžæçã«åæ¢ããããã®æç¹ã§ã®å€æ°ã®å€ãªã©ã確èªã§ããããã«ãããã®ã§ããAndroid Studioã§ã¯ãå€æ°ã®å€ããªã¢ã«ã¿ã€ã ã§ç£èŠãããŠã©ããæ©èœãå©çšã§ããŸãã
ãŸãããã°åºåã䜿çšããŠãç¹å®ã®ã³ãŒããå®è¡ãããéã«æ å ±ãã³ã³ãœãŒã«ã«åºåãããæ¹æ³ããããŸããLogcatãŠã£ã³ããŠã䜿ã£ãŠãã¢ããªãéåºãããã°ã¡ãã»ãŒãžããã£ã«ã¿ããŠé²èŠ§ã§ããŸããå¹ççãªãããã°ãè¡ãããšã§ãä¿¡é Œæ§ã®é«ãã¢ããªã±ãŒã·ã§ã³ããªãªãŒã¹ããããšãã§ããŸãã
5. UIãã¶ã€ã³ïŒJavaã§ã®ã€ã³ã¿ãŒãã§ãŒã¹äœæ
Androidã¢ããªã±ãŒã·ã§ã³ã«ãããŠãUIãã¶ã€ã³ã¯ãŠãŒã¶ãŒäœéšã倧ããå·Šå³ããŸããJavaã䜿çšããã¢ããªéçºã§ã¯ããã¥ãŒã³ã³ããŒãã³ããã¬ã€ã¢ãŠããããŒãžã£ããŠã£ãžã§ãããªã©ãé§äœ¿ããŠãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ãäœæããŸãããã®ç« ã§ã¯ãã®åºæ¬ãçæéã§å¹ççã«ç解ã§ããããã«è§£èª¬ããŸãã
5.1 ãã¥ãŒã³ã³ããŒãã³ãã®æŠèŠ
ãã¥ãŒã³ã³ããŒãã³ãã¯ãAndroidã¢ããªã®åºæ¬çãªãã«ãã£ã³ã°ãããã¯ã§ããTextViewãButtonãImageViewãªã©ãåçš®ãŠã£ãžã§ãããç»é¢ã«é 眮ããŠãããŸããJavaã³ãŒãå ã§ãã¥ãŒã³ã³ããŒãã³ããå¶åŸ¡ããããšã§ãåçãªUIã®å€æŽãå¯èœã«ãªããŸãã
ãã¥ãŒã³ã³ããŒãã³ãã¯XMLã¬ã€ã¢ãŠããã¡ã€ã«ã§å®£èšçã«èšè¿°ããããšãäž»æµã§ãããå¿ èŠã«å¿ããŠJavaã³ãŒããããçæã»ä¿®æ£ãå¯èœã§ããããã«ããã¢ããªã®æ¯ãèãã«åãããæè»ãªUIå€æŽãå®çŸã§ããŸãã
ãŸããã¢ããªãåœéåãããŠããå Žåã¯ãè€æ°èšèªã«ã察å¿ããå¿ èŠããããŸãããã¥ãŒã³ã³ããŒãã³ãã䜿çšããäžã§ããªãœãŒã¹ãã¡ã€ã«ãé©åã«ç®¡çããããšãéèŠã§ãã
5.2 ã¬ã€ã¢ãŠããããŒãžã£ã®äœ¿ãæ¹
ã¬ã€ã¢ãŠããããŒãžã£ã¯ããã¥ãŒã³ã³ããŒãã³ããã©ã®ããã«é 眮ãããã決å®ããŸããLinearLayoutãRelativeLayoutãªã©ãå€ãã®ã¬ã€ã¢ãŠããããŒãžã£ãAndroidã«çšæãããŠããŠãç°ãªãã¬ã€ã¢ãŠãèŠä»¶ã«å¿ããŠéžæã䜿çšããŸãã
ããããã®ã¬ã€ã¢ãŠããããŒãžã£ã¯ç¹å®ã®ã¬ã€ã¢ãŠãããžãã¯ãæã£ãŠããããããç解ããããšã§ãã¢ããªã®èŠãç®ãšæ©èœãç°¡åã«èª¿æŽã§ããŸããäŸãã°ãLinearLayoutã§ã¯ãã¥ãŒãäžåã«äžŠã¹ãRelativeLayoutã§ã¯ã³ã³ããŒãã³ãã®çžå¯Ÿçäœçœ®ã§é 眮ããŸãã
ã¬ã€ã¢ãŠããããŒãžã£ã®éžæãšé©çšã¯ãã¢ããªã®æ§èœã«ã倧ãã圱é¿ãäžãããããããã©ãŒãã³ã¹ãèæ ®ããªããé©åãªãã®ãéžã¶ããšãéèŠã§ããã¬ã€ã¢ãŠãã®ãã¹ããæ·±ããããšããã©ãŒãã³ã¹ãäœäžããããããã©ãããªæ§é ãæšå¥šãããŸãã
5.3 ãŠã£ãžã§ãããšã€ã³ã¿ã©ã¯ã·ã§ã³èŠçŽ
ãŠã£ãžã§ããã¯ãŠãŒã¶ãŒãã¢ããªãšå¯Ÿè©±ããããã®ã€ã³ã¿ãŒãã§ãŒã¹èŠçŽ ã§ãããã¿ã³ãããã¹ããã£ãŒã«ããã¹ã€ããããã§ãã¯ããã¯ã¹ãªã©ãããã«ããããŸããJavaã§ã¯ãããã®ãŠã£ãžã§ããã«å¯ŸããŠãªã¹ããŒãèšå®ãããŠãŒã¶ãŒã®ã¢ã¯ã·ã§ã³ã«åå¿ãããŸãã
åãŠã£ãžã§ããã¯ç¹å®ã®ã€ãã³ãã«å¯ŸããŠãªã¹ããŒãæã¡ãäŸãã°ãã¿ã³ã§ã¯OnClickListenerãèšå®ããããšã§ã¯ãªãã¯ã€ãŽã§ã³ããææã§ããŸããéçºè ã¯ãããå©çšããŠããã¿ã³ãã¿ãããããæã®åŠçãèšè¿°ããããšãã§ããŸãã
ã€ã³ã¿ã©ã¯ã·ã§ã³èŠçŽ ãèšèšããéã«ã¯ããŠãŒã¶ããªãã£ãæ倧éã«èæ ®ããå¿ èŠããããŸãã䜿ãããããã¢ã¯ã»ã·ããªãã£ãã€ã³ã¿ã©ã¯ãã£ããã£ãŒãããã¯ãé©åãªãŠã£ãžã§ããèšèšã®éµã§ãã
5.4 ã¬ã¹ãã³ã·ããã¶ã€ã³ã®åºæ¬
ã¬ã¹ãã³ã·ããã¶ã€ã³ã¯ãããŸããŸãªããã€ã¹ãµã€ãºã解å床ã«å¯Ÿå¿ããããã®ãã¶ã€ã³ææ³ã§ããAndroidã¢ããªã§ã¯ãç°ãªãç»é¢ãµã€ãºã®ããã€ã¹ã§äžè²«ãããŠãŒã¶ãŒäœéšãæäŸããããã«ãã®ææ³ãäžå¯æ¬ ã§ãã
dpïŒdensity-independent pixelsïŒã䜿çšããããšã§ãç°ãªã解å床ã®ããã€ã¹ã«å¯Ÿå¿ããã¹ã±ãŒã©ãã«ãªUIãã¶ã€ã³ãå®çŸã§ããŸãããŸããç»é¢ã®åããå€ãã£ãå Žåã«ããã¬ãã·ãã«ã«ã¬ã€ã¢ãŠããå€æŽã§ãããããã¬ã€ã¢ãŠããªãœãŒã¹ãåããŠç®¡çããããšãæšå¥šãããŸãã
æçµçã«ã¢ããªã®åãã¥ãŒãã©ã®ããã«ã¬ã³ããªã³ã°ããããã¯ãã¬ã€ã¢ãŠããã¡ã€ã«ã«æå®ãããå±æ§ãšããã€ã¹ã®ç¹æ§ã«å¿ããŠå€åããŸããéçºè ã¯ã¬ã¹ãã³ã·ããã¶ã€ã³ã®ååã«åŸãããã¹ããç¹°ãè¿ãããšã§ãå¹ åºããŠãŒã¶ãŒã«é©ããã¢ããªã±ãŒã·ã§ã³ãäœæã§ããŸãã
6. JavaãšAndroidã®APIã®æŽ»çš
Javaã䜿çšããAndroidã¢ããªéçºã«ãããŠãAndroidã®APIã掻çšããããšã¯äžå¯æ¬ ã§ããAPIã¯ãã¢ããªã±ãŒã·ã§ã³ããã°ã©ãã³ã°ã€ã³ã¿ãŒãã§ãŒã¹ã®ç¥ã§ãããã°ã©ã ãã·ã¹ãã ãã©ã€ãã©ãªãšãããšãããããã®èŠçŽãæå³ããŸããAndroid APIãå©çšããããšã§ãã«ã¡ã©æäœãããŒã¿ä¿åããããã¯ãŒã¯éä¿¡ãªã©ãã¹ããŒããã©ã³ã®è±å¯ãªæ©èœãã¢ããªå ã§å©çšã§ããããã«ãªããŸãã
Javaã§ã®éçºã§ã¯ãæšæºAPIãã¯ãããšããå€æ§ãªã©ã€ãã©ãªããµããŒããããŠãããããããããŸãçµã¿åãããŠäœ¿ãããšã§ãå¹ççãã€æ©èœçãªã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããããšãå¯èœã§ããããã§ã¯ãæšæºAPIã®å©çšæ¹æ³ãããŒã¿ä¿åããããã¯ãŒã¯æäœãã»ã³ãµãŒãã«ã¡ã©ã®ããã°ã©ãã³ã°ã«ã€ããŠç°¡åã«è§£èª¬ããŠãããŸãã
APIã掻çšããéã¯ãããã¥ã¡ã³ãããã£ãããšèªã¿èŸŒã¿ãã©ã®ãããªæ©èœãæäŸãããŠããã®ããã©ã®ããã«äœ¿ãã®ããç解ããããšãéèŠã§ããAndroidéçºã§ã¯ãå ¬åŒããã¥ã¡ã³ããéåžžã«å å®ããŠããããµã³ãã«ã³ãŒããšãšãã«APIã®äœ¿çšæ¹æ³ã解説ãããŠããŸãã
6.1 æšæºAPIã®å©çšæ¹æ³
Androidéçºã«ãããŠãTextView衚瀺ããã¿ã³ã€ãã³ãã®ãããªåºæ¬çãªUIæäœããããã¡ã€ã«åŠçãã¹ã¬ãã管çãªã©å¹ åºãæ©èœã«ããã£ãŠãæšæºAPIãæäŸãããŠããŸãããããã¯ãAndroid SDKã®äžéšãšããŠçµã¿èŸŒãŸããŠãããAndroid Studioã§éçºããéã«ã¯ãèªåçã«ã€ã³ããŒããããŠå©çšå¯èœã§ãã
æšæºAPIãå©çšããã«ã¯ãé©åãªimportæããã¡ã€ã«ã®å é ã«èšè¿°ããããšã§ãã¯ã©ã¹ãã¡ãœããã«ã¢ã¯ã»ã¹ã§ããããã«ãªããŸããäŸãã°ãArrayListã䜿çšããå Žåã¯ãimport java.util.ArrayList;ãã®ããã«èšè¿°ããŸãã
UIã³ã³ããŒãã³ãã®æäœããæšæºAPIãéããŠè¡ããŸããäŸãã°ããã¿ã³ã«OnClickListenerãèšå®ããã¯ãªãã¯ã€ãã³ãããã³ããªã³ã°ããããšãå¯èœã§ããAPIããã¥ã¡ã³ãã«åŸã£ãŠæ£ããæ§æã§ã³ãŒãã£ã³ã°ããããšããã¢ããªéçºã®åºæ¬ãšãªããŸãã
6.2 ããŒã¿ä¿åïŒShared PreferencesãšããŒã¿ããŒã¹
ã¢ããªéçºã«ãããŠããŒã¿ãä¿åããæ¹æ³ã¯ããã€ããããŸãããã·ã³ãã«ãªããŒãšããªã¥ãŒã®ãã¢ã§ããŒã¿ãä¿åããã®ã«äŸ¿å©ãªã®ãShared Preferencesã§ããèšå®å€ã®ä¿åã«é©ããŠãããç°¡åã«èªã¿æžããã§ããŸãã
Shared Preferencesã䜿çšããã«ã¯ãgetSharedPreferencesã¡ãœãããåŒã³åºããä¿åãããããŒã¿ãputStringãputBooleanãªã©ã®ã¡ãœããã§æ ŒçŽããŸããã³ãããããéã«ã¯ãeditã¡ãœããã§ååŸããEditorãçµç±ããcommitãããã¯applyã¡ãœãããåŒã³åºããŸãã
äžæ¹ããã£ãšè€éãªããŒã¿æ§é ã倧éã®ããŒã¿ãæ±ãå¿ èŠãããå Žåã¯ãSQLiteããŒã¿ããŒã¹ã®æŽ»çšãæ€èšããå¿ èŠããããŸããAndroidã§ã¯SQLiteOpenHelperã¯ã©ã¹ãç¶æ¿ããããŒã¿ããŒã¹ã®äœæãšããŒãžã§ã³ç®¡çãè¡ãããšã§ãç¬èªã®ããŒã¿ããŒã¹ãã¢ããªå ã§å©çšã§ããããã«ãªããŸãã
6.3 ãããã¯ãŒã¯æäœãšAPIéä¿¡ã®åºæ¬
Androidã¢ããªã§ã¯ãREST APIãªã©ã®ãŠã§ããµãŒãã¹ãšéä¿¡ããããšãå€ããããŒã¿ã®ããåããè¡ãããã«ãããã¯ãŒã¯æäœãå¿ èŠã«ãªã£ãŠããŸããHttpURLConnectionã¯ã©ã¹ããAndroid ã«çµã¿èŸŒãŸããŠããVolleyã©ã€ãã©ãªã䜿ãããšã§ãHTTPãªã¯ãšã¹ããéåä¿¡ã§ããŸãã
éä¿¡ãè¡ãéã«ã¯ãéåæåŠçãå®è¡ããå¿ èŠããããAndroidã§ã¯AsyncTaskãå©çšããããã³ãŒã«ããã¯ãé©åã«åŠçããããšãæ±ããããŸããããã«ãããã¡ã€ã³ã¹ã¬ããã§ã®é·æéã®åŠçãé¿ããã¢ããªã®ããã©ãŒãã³ã¹ãç¶æã§ããŸãã
Volleyã¯ããããã¯ãŒã¯ãªã¯ãšã¹ãã®ãã¥ãŒã€ã³ã°ããã£ãã·ã¥ãã¹ã¬ãã管çãªã©ãè€éãªãããã¯ãŒã¯æäœãç°¡åã«å®è¡ã§ããå©ç¹ããããå°ãªãã³ãŒãã§åŒ·åãªãããã¯ãŒã¯ã¢ããªã±ãŒã·ã§ã³ãäœæã§ããŸãã
6.4 ã»ã³ãµãŒãšã«ã¡ã©ã®ããã°ã©ãã³ã°
Androidã¹ããŒããã©ã³ã¯ãå é床ã»ã³ãµãŒããžã£ã€ãã¹ã³ãŒããªã©ã®ããŸããŸãªã»ã³ãµãŒãæèŒããŠãããããããããã°ã©ã ããå©çšããããšãå¯èœã§ããã»ã³ãµãŒããŒã¿ã®ååŸã«ã¯ãSensorManagerã䜿çšããç»é²ãããªã¹ããŒãéããŠããŒã¿ãååŸããŸãã
ã«ã¡ã©ã®æäœãAndroid APIã䜿ã£ãŠæ¯èŒçç°¡åã«è¡ããŸããCameraã¯ã©ã¹ã䜿çšããŠã«ã¡ã©ã®ãã¬ãã¥ãŒãåçã®æ®åœ±ãã³ã³ãããŒã«ããæ®åœ±ããåçããŒã¿ãåŠçããããšãã§ããŸãããã ããCamera2 APIã«ãã£ãŠæäŸãããé«åºŠãªæ©èœãå©çšããå Žåã¯ããè€éãªã³ãŒãã£ã³ã°ãå¿ èŠã«ãªãå ŽåããããŸãã
ãããã®APIã䜿ãããšã§ãã»ã³ãµãŒãã«ã¡ã©ã掻çšããå€çš®å€æ§ãªã¢ããªã±ãŒã·ã§ã³ãéçºããããšãã§ããŸãããã ãããŠãŒã¶ãŒã®ãã©ã€ãã·ãŒãå°éããèš±å¯ãåŸãããããŒã¿ãå®å šã«æ±ã£ããããããšãéèŠã§ãã
7. å®äŸã§åŠã¶Javaã䜿ã£ãAndroidã¢ããªéçº
7.1 ãµã³ãã«ã¢ããªã±ãŒã·ã§ã³ã®çŽ¹ä»ãšæŠèŠ
ã¢ããªéçºãåŠã¶ã«ã¯ãå®éã«ãµã³ãã«ã¢ããªã±ãŒã·ã§ã³ãäœæãããã®ããã»ã¹ãéããŠå¿ èŠãªç¥èãã¹ãã«ã身ã«ã€ããããšãå¹æçã§ãããã®ç« ã§ã¯ãåºæ¬çãªToDoãªã¹ãã¢ããªãäºäŸã«æãããã®éçºéçšã詳ãã解説ããŸãã
ãµã³ãã«ã¢ããªã±ãŒã·ã§ã³ã¯ããŠãŒã¶ãŒãæ¥ã ã®ã¿ã¹ã¯ãå ¥åãã管çããæ©èœãæã£ãŠããŸãããŸããåã¿ã¹ã¯ã«ã¯åªå 床ãèšå®ã§ããæ¥æã«å¿ããŠéç¥ãåãåãããšãå¯èœã§ãããã®ã¢ããªã¯ãäžé£ã®Androidéçºã®åºæ¬çãªæŠå¿µãç¶²çŸ ããŠãããããåå¿è ã§ãç解ããããã§ãããã
ãã®ã¢ããªã¯ãUI/UXèšèšãããŒã¿ã®ä¿åãšèªã¿åºããããã¯ã°ã©ãŠã³ãããã»ã¹ã®åãæ±ãããããŠãŠãŒã¶ãŒéç¥ã®èšå®ãªã©ãAndroid ã¢ããªéçºã®äž»èŠãªåŽé¢ãäœéšããããšãã§ããŸãããããã®èŠçŽ ãåŠã¶ããšã§ãå®çšçãªã¢ããªã®éçºèœåã身ã«ã€ããããšãã§ããŸãã
7.2 æ©èœå¥ã®ã³ãŒãã£ã³ã°ãã¯ããã¯
å¹ççãªã¢ããªéçºãè¡ãããã«ã¯ãåæ©èœã®ã³ãŒãã£ã³ã°ãã¯ããã¯ãç解ããããšãéèŠã§ããããšãã°ããªã¹ãã®è¡šç€ºã«ã¯RecyclerViewã䜿çšããŸããããã¯ãããŒã¿ã®éãå€ããªã£ãŠãã¹ã ãŒãºãªã¹ã¯ããŒã«ãå¯èœã«ãããªãœãŒã¹ã®äœ¿çšãæé©åããããã®ã³ã³ããŒãã³ãã§ãã
ããŒã¿ã®ä¿åã«ã¯ãSQLiteããŒã¿ããŒã¹ãSharedPreferencesã掻çšããæ¹æ³ãäžè¬çã§ããSQLiteã¯è€éãªããŒã¿æ§é ãæã€ããŒã¿ãä¿åããã®ã«é©ããŠããäžæ¹ã§ãSharedPreferencesã¯åçŽãªããŒãšå€ã®ãã¢ã®ä¿åã«çšããŸãã䜿çšããæ©èœãšèŠä»¶ã«ãã£ãŠæé©ãªæ¹æ³ãéžã¶ããšããã€ã³ãã§ãã
ãŸãããŠãŒã¶ãŒã®æäœã«å¿ããã€ãã³ããã³ããªã³ã°ã¯ãã¢ããªã®äœ¿ãåæã倧ããå·Šå³ããŸããOnClickListenerãOnTouchListenerãªã©ã®ãªã¹ããŒãèšå®ããããšã§ããŠãŒã¶ãŒã®ã¿ãããã¯ãªãã¯ãªã©ã®ã¢ã¯ã·ã§ã³ãæ€åºãã察å¿ããåäœãããã°ã©ã ããå¿ èŠããããŸãã
7.3 ããã©ãŒãã³ã¹æé©åã®ãã³ã
ã¢ããªã®ããã©ãŒãã³ã¹ãæé©åããããšã¯ããŠãŒã¶ãŒãå¿«é©ã«ã¢ããªã䜿çšãç¶ããããã«å¿ é ã§ããã¡ã¢ãªãªãŒã¯ã®é²æ¢ãå¹ççãªããŒã¿æ§é ã®äœ¿çšãé©åãªãªãœãŒã¹ç®¡çã¯ãããã©ãŒãã³ã¹åäžã®ããã«éèŠãªãã€ã³ãã§ãã
ã¢ããªã䜿çšããç»åããªãœãŒã¹ã®ãµã€ãºãé©åã«ç®¡çããããšããã¡ã¢ãªäœ¿çšéãæžãããã¢ããªã®åå¿é床ãé«ããããã«åœ¹ç«ã¡ãŸãããŸããäžèŠãªãªããžã§ã¯ãåç §ãé¿ããã¬ãŒããŒãžã³ã¬ã¯ã·ã§ã³ã®é »åºŠãæžããããšãããã©ãŒãã³ã¹ãæé©åããäžã§æå¹ã§ãã
ããã¯ã°ã©ãŠã³ãããã»ã¹ã¯ãã¢ããªã®ããã©ãŒãã³ã¹ã«å€§ããªåœ±é¿ãäžããŸããäŸãã°ããããã¯ãŒã¯éä¿¡ãããŒã¿ããŒã¹ã®æäœã¯ãå¯èœãªéãéåæã§è¡ãããšãæšå¥šãããŸãããã®ãããªåŠçãAsyncTaskãIntentServiceã䜿ã£ãŠæé©åããããšã¯ãã¹ã ãŒãºãªUIã®ç¶æã«å¯äžããŸãã
7.4 ã¢ããªã®å ¬éæºåãšGoogle Playã§ã®é ä¿¡
éçºããã¢ããªã±ãŒã·ã§ã³ãå€ãã®ãŠãŒã¶ãŒã«å±ããããã«ã¯ãGoogle Playã§ã®é ä¿¡ãäžè¬çãªæ¹æ³ã§ããã¢ããªã®å ¬éåã«ã¯ããããã¯ãåãã¢ã€ã³ã³ã説ææãªã©ã確å®ãããŸãããŸããããŒã¿ãã¹ããè¡ããåæã®ãã£ãŒãããã¯ãéããããšã倧åã§ãã
Google Play ConsoleãéããŠã¢ããªãå ¬éããéã«ã¯ãAPKãã¡ã€ã«ãã¢ããããŒãããã¹ãã¢ãªã¹ãã£ã³ã°ã®è©³çŽ°ãå ¥åããå¿ èŠããããŸããããã«ã¯é©åãªã¹ã¯ãªãŒã³ã·ã§ãããããŠãŒã¶ãŒã«é åçãªã¢ããªèª¬ææãå¿ èŠã§ããé©åãªããŒã¯ãŒãã®éžå®ãèŠéããªããã€ã³ãã§ãã
æåŸã«ãã¢ããªã®äŸ¡æ Œèšå®ã察象åœã®èšå®ããã©ã€ãã·ãŒããªã·ãŒã®ç¢ºèªãªã©ã®ã¹ããããèžãã åŸãã¢ããªã®ã¬ãã¥ãŒãGoogle Playã®ããŒã ã«éä¿¡ããŸããåé¡ããªããã°ã¢ããªã¯ã¹ãã¢ã§ã®é ä¿¡ãéå§ãããŸãããå Žåã«ãã£ãŠã¯è¿œå ã®æ å ±æäŸãæ±ããããããšããããŸãã
8. ãŸãšãïŒ10åã§åŠãã Androidéçºã®èŠç¹ãšæ¬¡ã®ã¹ããã
8.1 10åã§åŠãã éèŠèŠçŽ ã®ã¬ãã¥ãŒ
ãã®çãæéã§ãAndroidéçºã®åºæ¬çãªåŽé¢ã«ã€ããŠæŠèŠ³ããŸããããŸããã¢ããªã±ãŒã·ã§ã³ã®æ§é ãªã©ã®åºæ¬ããå§ãŸããJavaèšèªã®å¹æçãªäœ¿çšæ¹æ³ããããŠAndroidã®äž»èŠãªAPIãšãã¬ãŒã ã¯ãŒã¯ãç解ããããšãéèŠã§ããã¬ã€ã¢ãŠãã®èšå®ãã€ãã³ãã®åŠçãªã©ãæãåãããªããåŠã¶ããšã§åºæ¬ã身ã«ã€ãã§ãããã
ãŸããAndroid StudioãGradleãªã©ã®éçºããŒã«ã«ã觊ãããããã䜿çšããŠå¹çè¯ãã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããæ¹æ³ãåŠã³ãŸããããããã°ãšãã¹ãã®åºæ¬çãªæµããç¥ãããšã§ããã°ã®å°ãªãä¿¡é Œæ§ã®é«ãã¢ããªãäœãããšãã§ããŸãã
æåŸã«ããã¶ã€ã³ååããŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ã«ãçæããå¿ èŠããããŸããããããèŠçŽ ã¯ã¢ããªã®æåã«çŽæ¥é¢ãã£ãŠãããããAndroidã®ã¬ã€ãã©ã€ã³ã«æ²¿ã£ãŠåªããã€ã³ã¿ãŒãã§ã€ã¹ãèšèšããããšãæšå¥šãããŸãã
8.2 ä»åŸã®åŠç¿ãã¹ãšè³æº
ãã®å ¥éã¬ãã¥ãŒã®åŸãããã«æ·±ãç¥èã身ã«ã€ãããå Žåã¯ãå ¬åŒã®ããã¥ã¡ã³ããŒã·ã§ã³ããªã³ã©ã€ã³ã³ãŒã¹ã掻çšããã®ãè¯ãã§ãããããªã³ã©ã€ã³ã«ã¯ç¡æã§ã¢ã¯ã»ã¹ã§ããè±å¯ãªãã¥ãŒããªã¢ã«ããããŸããäŸãã°ãGoogleã®Android DevelopersãŠã§ããµã€ãã¯ãåºæ¬ããå¿çšãŸã§å¹ åºããããã¯ãç¶²çŸ ããŠããŸãã
ãŸããã ãŒãã³ã°ã¢ãããç®æããªããKotlinãžã®ç§»è¡ãæ€èšããŠã¿ãŠãã ãããKotlinã¯Googleãå ¬åŒã®Androidã¢ããªã±ãŒã·ã§ã³èšèªãšããŠæšå¥šããŠãããJavaãšæ¯ã¹ãŠããç°¡æœã§å¹ççãªã³ãŒããèšè¿°ã§ãããšè©å€ã§ãã
å ããŠãGitHubãStack Overflowãšãã£ããã©ãããã©ãŒã ã«ã泚ç®ããŸãããããããã®ãµã€ãã¯åé¡è§£æ±ºã«åœ¹ç«ã€ã³ãŒãã¹ããããããå®éã®éçºã«ãããŠééãããããããªãåé¡ã«å¯Ÿãã解決çãèŠã€ããã®ã«æçšã§ãã
8.3 ã³ãã¥ããã£ãšãã©ãŒã©ã ã®æŽ»çš
ããã«äžéããããã«ã¯ãAndroidéçºè ã³ãã¥ããã£ãšç©æ¥µçã«é¢ããããšãéèŠã§ããããŒã«ã«ã®éçºè ã°ã«ãŒãããã©ãŒã©ã ã«åå ããããšã§ãçµéšè±å¯ãªéçºè ããå®è·µçãªã¢ããã€ã¹ãåŸãããŸãããŸããã¡ã³ã¿ãŒãååãšã®ã³ãŒãã£ã³ã°ã»ãã·ã§ã³ãéããŠåŠã³ãæ·±ããããšãã§ããŸãã
ã³ãã¥ããã£ã«ã¯åå¿è ãããããã§ãã·ã§ãã«ãŸã§ããŸããŸãªã¬ãã«ã®äººãããŸãã®ã§ã質åãæããããŸãèªåã®ç¥èãä»ã®ã¡ã³ããŒãšå ±æããŠãã ãããããããããšã§ãæ°ããèŠç¹ãåŸãããç¥èã®å®çãå³ãããšãã§ããŸãã
FacebookãLinkedInãRedditçã®ãœãŒã·ã£ã«ã¡ãã£ã¢ã«ãå€ãã®Androidéçºè ã³ãã¥ããã£ãååšããæ å ±äº€æã®å Žãšãªã£ãŠããŸãããããã®ãã©ãããã©ãŒã ãå©çšããŠãäžçäžã®éçºè éãšã€ãªãããŸãããã
8.4 ç¶ç¶çãªéçºãšã¢ããããŒãã®éèŠæ§
æè¡ã¯çµ¶ããé²åããŠãããããAndroidéçºè ãšããŠèªèº«ã®ã¹ãã«ã»ãããç¶ç¶çã«ã¢ããããŒãããããšãæ±ããããŸããæ°ããããŒãžã§ã³ã®Android OSããšã«æ°æ©èœãè¿œå ããããããææ°ã®ãã¬ã³ããããŒã«ã«åžžã«ç®ãåããŠããå¿ èŠããããŸãã
ãŸããèªåã®ã¢ããªãåžå Žã«æå ¥ããåŸãããŠãŒã¶ãŒããã®ãã£ãŒãããã¯ã«åºã¥ããŠå®æçãªã¢ããããŒããæ©èœã®è¿œå ãè¡ãªã£ãŠããã¹ãã§ããããã«ãã£ãŠãã¢ããªã®ãŠãŒã¶ããªãã£ãã»ãã¥ãªãã£ãåäžããããå€ãã®ãŠãŒã¶ãŒã«æãããã¢ããªã«æé·ããŠãããŸãã
æçµçã«ã¯ãç¶ç¶çãªåŠç¿ãšã¢ããããŒãããããã§ãã·ã§ãã«ãšããŠæåããããã®éµã§ããæ¥ã ã®éçºäœæ¥ã®äžã§æ°ããææŠãæããããã£ãŒãããã¯ãç©æ¥µçã«åãå ¥ããäžæ©ãã€åé²ããŠãããŸãããã
9. ãŸãšã
ããžãã¹ããŒãœã³ã«åããAndroidéçºã®å ¥éã¬ã€ãã10åã§Androidãã©ãããã©ãŒã ã®æŠèŠããJavaã䜿ã£ãã¢ããªæ§ç¯ãŸã§ã®æµãããã£ããç解ãåããŠã®Hello Worldã¢ããªå¶äœãããã¬ã€ã¢ãŠããã¶ã€ã³ãAPIå©çšãããŒã¿ãã³ããªã³ã°ãããã©ãŒãã³ã¹æé©åã®ãã€ã³ããŸã§ãåŠãã ããšã®ã¬ãã¥ãŒãšä»åŸã®èªå·±ç éœã«åœ¹ç«ã€ãªãœãŒã¹ã玹ä»ããŸããã³ãã¥ããã£ãžã®åå ã§ãæç¶å¯èœãªéçºã¹ãã«ã身ã«ã€ããŸãããã