{"id":7374,"date":"2011-07-07T13:00:07","date_gmt":"2011-07-07T04:00:07","guid":{"rendered":"http:\/\/www.sssg.org\/blogs\/hiro345\/?p=7374"},"modified":"2011-07-10T08:07:56","modified_gmt":"2011-07-09T23:07:56","slug":"android%e3%82%a2%e3%83%97%e3%83%aa%e3%81%a7%e3%81%ae%e3%83%a2%e3%83%87%e3%83%ab%e8%a1%a8%e7%8f%be%e6%96%b9%e6%b3%95%e3%82%92%e8%80%83%e3%81%88%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/7374.html","title":{"rendered":"Android\u30a2\u30d7\u30ea\u3067\u306e\u30e2\u30c7\u30eb\u8868\u73fe\u65b9\u6cd5\u3092\u8003\u3048\u308b"},"content":{"rendered":"<p>\u4e00\u822c\u7684\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u3042\u305f\u3063\u3066\u306f\u3001\u6271\u3046\u5bfe\u8c61\u306e\u30c7\u30fc\u30bf\u30e2\u30c7\u30eb\u5316\u304c\u5fc5\u8981\u3067\u3059\u304b\u3089\u3001Android\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3059\u308b\u306b\u3042\u305f\u3063\u3066\u3082\u3001\u540c\u69d8\u306e\u3053\u3068\u304c\u3044\u3048\u307e\u3059\u3002\u305d\u306e\u969b\u3001\u30e2\u30c7\u30eb\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u3069\u306e\u3088\u3046\u306b\u8868\u73fe\u3059\u308b\u306e\u304b\u8003\u3048\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u7c21\u5358\u306aAndroid\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3059\u308b\u306b\u3042\u305f\u308a\u3001\u3069\u3093\u306a\u65b9\u6cd5\u304c\u3042\u308a\u305d\u3046\u304b\u8003\u3048\u305f\u306e\u3067\u3001\u3053\u3053\u306b\u30e1\u30e2\u3092\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><!--more--><br \/>\n<strong>\u5358\u7d14\u306a\u30a2\u30d7\u30ea<\/strong><br \/>\n\u753b\u9762\u304c1\u3064\u3057\u304b\u7121\u3044\u3088\u3046\u306a\u30b7\u30f3\u30d7\u30eb\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001Activity\u3092\u62e1\u5f35\u3057\u305f\u30af\u30e9\u30b9\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3068\u3057\u3066\u4fdd\u6301\u3059\u308b\u306e\u304c\u5358\u7d14\u3067\u3088\u3044\u3067\u3057\u3087\u3046\u3002\u753b\u9762\u63cf\u753b\u3092\u3059\u308b\u306b\u305b\u3088\u3001\u4f55\u304b\u51e6\u7406\u3092\u3059\u308b\u306b\u305b\u3088\u3001Activity\u7d4c\u7531\u3068\u306a\u308a\u307e\u3059\u304b\u3089\u3001\u305d\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3068\u3057\u3066\u304a\u3051\u3070\u3001\u56f0\u308b\u3053\u3068\u306f\u306a\u3044\u306f\u305a\u3067\u3059\u3002<\/p>\n<p><strong>\u8907\u6570\u306eActivity\u3092\u6301\u3064\u30a2\u30d7\u30ea<\/strong><br \/>\n\u8907\u6570\u306eActivity\u3092\u6301\u3064\u30a2\u30d7\u30ea\u3067\u30e2\u30c7\u30eb\u60c5\u5831\u3092\u5171\u6709\u3059\u308b\u306b\u306f\u3001\u3044\u304f\u3064\u304b\u65b9\u6cd5\u304c\u3042\u308b\u306e\u3067\u7528\u9014\u306b\u5fdc\u3058\u3066\u691c\u8a0e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n<ul>\n<li>a) Singleton\u30af\u30e9\u30b9\u3092\u7528\u610f\u3057\u3066\u5171\u6709\u3059\u308b<\/li>\n<li>b) Application\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3057\u3066\u72ec\u81ea\u30af\u30e9\u30b9\u3092\u7528\u610f\u3057\u3066\u5171\u6709\u3059\u308b<\/li>\n<li>c) \u72ec\u81eaContentProvider\u30af\u30e9\u30b9\u3092\u7528\u610f\u3057\u3066\u5171\u6709\u3059\u308b<\/li>\n<li>d) Intent\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5f15\u304d\u6e21\u3059\u65b9\u6cd5\u3067\u5171\u6709\u3059\u308b<\/li>\n<li>e) \u305d\u306e\u4ed6\uff08SharedPreference, File, SQLite\uff09<\/li>\n<\/ul>\n<p>GoF\u306e\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u77e5\u3063\u3066\u3044\u308b\u306a\u3089\u3001\u300ca) Singleton\u30af\u30e9\u30b9\u3092\u7528\u610f\u3057\u3066\u5171\u6709\u300d\u3068\u3044\u3046Singleton\u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u4e00\u756a\u624b\u8efd\u3067\u3057\u3087\u3046\u3002\u5c02\u7528\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u308f\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3057\u3001\u4f7f\u3044\u3084\u3059\u3044\u65b9\u5f0f\u3067\u3059\u3002<\/p>\n<p>\u300cb) Application\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3057\u3066\u72ec\u81ea\u30af\u30e9\u30b9\u3092\u7528\u610f\u3057\u3066\u5171\u6709\u3059\u308b\u300d\u3068\u3044\u3046\u65b9\u6cd5\u3082\u3001\u305d\u308c\u306a\u308a\u306b\u304a\u624b\u8efd\u3067\u3059\u3002Singleton\u30d1\u30bf\u30fc\u30f3\u306f\u4e00\u5ea6\u30d1\u30bf\u30fc\u30f3\u3092\u5b66\u3076\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u77e5\u3063\u3066\u3044\u308c\u3070\u8ab0\u3067\u3082\u3067\u304d\u308b\u30af\u30e9\u30b9\u306eextends\u3092\u4f7f\u3046\u3060\u3051\u3067\u3059\u304b\u3089\u3001\u3088\u308a\u7c21\u5358\u3067\u3059\u3002\u307e\u305f\u3001Singleton \u30d1\u30bf\u30fc\u30f3\u306e\u5834\u5408\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5185\u306e\u3069\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089\u3067\u3082\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u63d0\u4f9b\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306e\u5834\u5408\u306fApplication\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3078\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3060\u3051\u304c\u5229\u7528\u3067\u304d\u308b\u3068\u3044\u3046\u5236\u9650\u3082\u3064\u304d\u307e\u3059\u3002\u306a\u304a\u3001Application\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3057\u305f\u72ec\u81ea\u30af\u30e9\u30b9\u3092\u7528\u610f\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001AndroidManifest.xml\u3078\u72ec\u81eaApplication\u30af\u30e9\u30b9\u306e\u767b\u9332\u3082\u5fc5\u8981\u3067\u3059\u304b\u3089\u3001\u6c17\u3092\u3064\u3051\u307e\u3057\u3087\u3046\u3002\u5404Activity\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089\u72ec\u81eaApplication\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53c2\u7167\u3059\u308b\u306b\u306f\u3001Context#getApplication()\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u300cc) \u72ec\u81eaContentProvider\u30af\u30e9\u30b9\u3092\u7528\u610f\u3057\u3066\u5171\u6709\u3059\u308b\u300d\u3068\u3044\u3046\u65b9\u6cd5\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u30ea\u30bd\u30fc\u30b9\u3084DB\u306b\u683c\u7d0d\u3057\u305f\u30c7\u30fc\u30bf\u3092\u5171\u6709\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002\u5c06\u6765\u3001\u4ed6\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3078\u3082\u30c7\u30fc\u30bf\u3092\u63d0\u4f9b\u3057\u305f\u3044\u3068\u8003\u3048\u3066\u3044\u308b\u306a\u3089\u3001\u753b\u9762\u9593\u3067\u5171\u6709\u3059\u308b\u30c7\u30fc\u30bf\u306b\u3064\u3044\u3066\u3082\u72ec\u81eaContentProvider\u30af\u30e9\u30b9\u3067\u51e6\u7406\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u306e\u304c\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u5358\u7d14\u306b\u753b\u9762\u9593\u306e\u30c7\u30fc\u30bf\u5171\u6709\u3092\u3059\u308b\u306b\u306f\u3001\u5927\u8888\u88df\u306a\u4ed5\u7d44\u307f\u3067\u3059\u3002\u3068\u306f\u3044\u3048\u3001\u97f3\u697d\u30c7\u30fc\u30bf\u3084\u52d5\u753b\u30c7\u30fc\u30bf\u306e\u3088\u3046\u306a\u3082\u306e\u306f\u30e1\u30e2\u30ea\u4e0a\u306b\u5c55\u958b\u3057\u3063\u3071\u306a\u3057\u3068\u3044\u3046\u308f\u3051\u306b\u3082\u3044\u304b\u306a\u3044\u3067\u3059\u3057\u3001\u5927\u91cf\u306e\u30c7\u30fc\u30bf\u306fDB\u3078\u683c\u7d0d\u3057\u3066\u4e00\u90e8\u306e\u30c7\u30fc\u30bf\u3060\u3051\u30e1\u30e2\u30ea\u4e0a\u306b\u7f6e\u3044\u3066\u304a\u304d\u305f\u3044\u306f\u305a\u3067\u3059\u3002\u305d\u3046\u3044\u3063\u305f\u30c7\u30fc\u30bf\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u306e\u65b9\u6cd5\u3092\u63a1\u7528\u3059\u308b\u306e\u304c\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u300cd) Intent\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5f15\u304d\u6e21\u3059\u65b9\u6cd5\u3067\u5171\u6709\u3059\u308b\u300d\u3068\u3044\u3046\u65b9\u6cd5\u306f\uff12\u3064\u306eActivity\u30af\u30e9\u30b9\u9593\u3067\u60c5\u5831\u306e\u3084\u308a\u3068\u308a\u3092\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002a)\u304b\u3089c)\u307e\u3067\u306f\u3069\u306eActivity\u30af\u30e9\u30b9\u9593\u3067\u3082\u30c7\u30fc\u30bf\u5171\u6709\u3092\u3057\u305f\u3044\u5834\u5408\u306e\u3082\u306e\u3067\u3057\u305f\u304c\u3001\u3053\u3061\u3089\u306f\u3001\u5225\u306eActivity\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u60c5\u5831\u3092\u6e21\u3057\u3066\u5171\u6709\u3059\u308b\u3068\u3044\u3046\u65b9\u6cd5\u306b\u306a\u308a\u307e\u3059\u3002\u5229\u7528\u3059\u308b\u30c7\u30fc\u30bf\u304c\uff12\u3064\u306eActivity\u30af\u30e9\u30b9\u9593\u3067\u3057\u304b\u610f\u5473\u3092\u6301\u305f\u306a\u3044\u3088\u3046\u306a\u3082\u306e\u306a\u3089\u3001\u3053\u306e\u65b9\u6cd5\u3082\u9078\u629e\u80a2\u306e\u3072\u3068\u3064\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u300ce) \u305d\u306e\u4ed6\uff08SharedPreference, File, SQLite\uff09\u300d\u306f\u57fa\u672c\u7684\u306b\u30c7\u30fc\u30bf\u306e\u6c38\u7d9a\u5316\u3068\u8a71\u304c\u7d50\u3073\u3064\u3044\u3066\u3044\u307e\u3059\u3002\u6c38\u7d9a\u5316\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u306e\u5171\u6709\u306f\u53ef\u80fd\u3067\u3059\u304c\u3001I\/O\u304c\u767a\u751f\u3059\u308b\u306e\u3067\u3001\u30e1\u30e2\u30ea\u4e0a\u3060\u3051\u3067\u51e6\u7406\u3092\u3059\u308b\u3088\u308a\u3082\u6027\u80fd\u7684\u306b\u4e0d\u5229\u3068\u306a\u308b\u306f\u305a\u3067\u3059\u3002\u307e\u305f\u3001\u30c7\u30fc\u30bf\u5171\u6709\u306e\u305f\u3081\u306e\u30b3\u30fc\u30c9\u304c\u5404Activity\u30af\u30e9\u30b9\u306b\u6563\u4e71\u3059\u308b\u3068\u3044\u3063\u305f\u3053\u3068\u306b\u306a\u308a\u3084\u3059\u3044\u3067\u3057\u3087\u3046\u3002\u5bfe\u8c61\u3068\u306a\u308b\u30c7\u30fc\u30bf\u3092\u3067\u304d\u308b\u3060\u3051\u6c38\u7d9a\u5316\u3057\u3066\u304a\u304d\u305f\u3044\u5834\u5408\u3067\u3001\u304b\u3064\u3001I\/O\u306a\u3069\u306b\u3088\u308b\u51e6\u7406\u8ca0\u8377\u3082\u305d\u308c\u307b\u3069\u6c17\u306b\u306a\u3089\u306a\u3044\u5834\u5408\u306b\u306f\u3001\u3053\u306e\u65b9\u6cd5\u3082\u691c\u8a0e\u3059\u308b\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u6c17\u304c\u3064\u3044\u305f\u7bc4\u56f2\u3067\u8a18\u8f09\u3057\u3066\u307f\u307e\u3057\u305f\u3002\uff08<a href=\"\/\/www.sssg.org\/blogs\/hiro345\/archives\/7388.html\">\u4f7f\u3044\u5206\u3051\u3057\u3088\u3046\uff01Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u304a\u3051\u308b\u30c7\u30fc\u30bf\u4fdd\u6301\u306e\u65b9\u6cd5\uff08\uff11\uff09<\/a>\u3078\u7d9a\u304f\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u822c\u7684\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306b\u3042\u305f\u3063\u3066\u306f\u3001\u6271\u3046\u5bfe\u8c61\u306e\u30c7\u30fc\u30bf\u30e2\u30c7\u30eb\u5316\u304c\u5fc5\u8981\u3067\u3059\u304b\u3089\u3001Android\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3059\u308b\u306b\u3042\u305f\u3063\u3066\u3082\u3001\u540c\u69d8\u306e\u3053\u3068\u304c\u3044\u3048\u307e\u3059\u3002\u305d\u306e\u969b\u3001\u30e2\u30c7\u30eb\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u3069\u306e\u3088\u3046\u306b\u8868\u73fe\u3059\u308b\u306e\u304b\u8003\u3048 &hellip; <a href=\"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/7374.html\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[107],"tags":[1214,532,533,534,1207],"class_list":["post-7374","post","type-post","status-publish","format-standard","hentry","category-android","tag-android","tag-application","tag-contentprovider","tag-intent","tag-java"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/7374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=7374"}],"version-history":[{"count":3,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/7374\/revisions"}],"predecessor-version":[{"id":7392,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/7374\/revisions\/7392"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=7374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=7374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=7374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}