{"id":2701,"date":"2011-02-20T03:11:35","date_gmt":"2011-02-19T18:11:35","guid":{"rendered":"http:\/\/www.ekesete.net\/log\/?p=2701"},"modified":"2011-04-02T16:43:58","modified_gmt":"2011-04-02T07:43:58","slug":"android-ndk-r5b-nativeactivity%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88","status":"publish","type":"post","link":"https:\/\/www.ekesete.net\/log\/?p=2701","title":{"rendered":"android-ndk-r5b NativeActivity\u306e\u30c6\u30b9\u30c8"},"content":{"rendered":"<p>android-ndk-r5\u304b\u3089NativeActivity\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u8a66\u3057\u306b\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/developer.android.com\/reference\/android\/app\/NativeActivity.html\">NativeActivity\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a><br \/>\n\u3092\u898b\u3064\u3064\u3001\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0(native-activity)\u3092\u524a\u3063\u3066\u3044\u3063\u3066\u5fc5\u9808\u90e8\u5206\u3092\u8a66\u3057\u3066\u307f\u305f\u3089\u3001<br \/>\n\u6700\u5c0f\u3060\u3068\u601d\u308f\u308c\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>NativeActivity\u306f2\u901a\u308a\u306e\u5b9f\u88c5\u65b9\u6cd5\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u4eca\u56de\u306fnative\u304b\u3089 android_native_app_glue \u3092\u4f7f\u3046\u3060\u3051\u3067\u52d5\u304f\u3089\u3057\u3044\u697d\u306a\u65b9\u3002<br \/>\n\u307e\u305ajava\u5074\u306e\u6e96\u5099\u3068\u3057\u3066eclipse\u3067\u7a7a\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u3063\u3066 AndroidManifest.xml \u306b\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8ffd\u52a0\u3002<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;height:300px;\"><div class=\"text codecolorer\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br \/>\n&lt;manifest xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;<br \/>\n&nbsp; &nbsp; &nbsp; package=&quot;net.ekesete.NDKr5_Test&quot;<br \/>\n&nbsp; &nbsp; &nbsp; android:versionCode=&quot;1&quot;<br \/>\n&nbsp; &nbsp; &nbsp; android:versionName=&quot;1.0&quot;&gt;<br \/>\n<br \/>\n&nbsp; &nbsp; &lt;application android:label=&quot;@string\/app_name&quot; android:hasCode=&quot;false&quot;&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;activity android:name=&quot;android.app.NativeActivity&quot;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:label=&quot;@string\/app_name&quot;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:configChanges=&quot;orientation|keyboardHidden&quot;&gt;<br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;meta-data android:name=&quot;android.app.lib_name&quot; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:value=&quot;native-activity&quot; \/&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;intent-filter&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;action android:name=&quot;android.intent.action.MAIN&quot; \/&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; \/&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/intent-filter&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/activity&gt;<br \/>\n&nbsp; &nbsp; &lt;\/application&gt;<br \/>\n<br \/>\n&nbsp; &nbsp; &lt;uses-sdk android:minSdkVersion=&quot;9&quot; \/&gt;<br \/>\n&lt;\/manifest&gt;<\/div><\/div>\n<p>\u3053\u308c\u3067java\u30bd\u30fc\u30b9\u306f\u7121\u3057\u3067\u3082\u3088\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>ndk\u5074\u306fsample\/native-activity\u306emain.c\u3092\u66f8\u304d\u63db\u3048\u3066<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;height:300px;\"><div class=\"text codecolorer\">#include &lt;jni.h&gt;<br \/>\n#include &lt;android\/log.h&gt;<br \/>\n#include &lt;android_native_app_glue.h&gt;<br \/>\n<br \/>\n#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, &quot;native-activity&quot;, __VA_ARGS__))<br \/>\n<br \/>\nvoid android_main(struct android_app* state) {<br \/>\n&nbsp; &nbsp; int count=0;<br \/>\n<br \/>\n&nbsp; &nbsp; \/\/ Make sure glue isn't stripped.<br \/>\n&nbsp; &nbsp; app_dummy();<br \/>\n<br \/>\n&nbsp; &nbsp; while(1)<br \/>\n&nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; LOGI(&quot;logtest %d&quot;,count);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; count++;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; if(count == 30)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; return;<br \/>\n}<\/div><\/div>\n<p>\u3068\u3044\u3046\u306e\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u30b3\u30fc\u30c9\u306e\u5185\u5bb9\u7684\u306b\u306f\u898b\u3066\u5206\u304b\u308b\u3068\u304a\u308a\u5358\u306badb\u306e\u30ed\u30b0\u306b\u6570\u5b57\u3092\u5410\u304f\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>android_main()\u306e\u4e2d\u306b\u3042\u308b<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">app_dummy();<\/div><\/div>\n<p>\u3092\u547c\u3070\u306a\u3044\u3068\u30e9\u30a4\u30d6\u30e9\u30ea(.so\u30d5\u30a1\u30a4\u30eb)\u306e\u30ed\u30fc\u30c9\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305amain\u95a2\u6570\u3067\u547c\u3093\u3067\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u5168\u304f\u4e2d\u3092\u898b\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u3053\u3044\u3064\u306f\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u3068\u30c0\u30df\u30fc\u306e\u753b\u9762\u3092\u51fa\u3057\u3066\u304f\u308c\u308b\u3060\u3051\u306e\u95a2\u6570\u306e\u3088\u3046\u3067\u3001<br \/>\n\u30bd\u30fc\u30b9\u5185\u90e8\u3067\u63cf\u753b\u3057\u306a\u3044\u3068\u771f\u3063\u9ed2\u306a\u753b\u9762\u304c\u51fa\u305f\u307e\u307e\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n#narive-activity\u306e\u5143\u306e\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9\u306fOpenGL\u3092\u4f7f\u3063\u3066\u4f55\u304b\u3057\u3066\u307e\u3059\u3002<br \/>\n\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\u3068\u3001\u30b3\u30fc\u30c9\u4e0a\u306f\u7d42\u4e86\u3067\u3059\u304c\u3001\u30ed\u30b0\u306b<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">android_app_destroy!<\/div><\/div>\n<p>\u3068\u51fa\u3066\u3082\u3001\u753b\u9762\u306f\u305d\u306e\u307e\u307e\u6b8b\u308a\u307e\u3059\u3002<br \/>\n\u7d42\u308f\u3089\u305b\u308b\u65b9\u6cd5\u3092\u5b9f\u88c5\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u307f\u305f\u3044\u3067\u3059\u3002<br \/>\n<center><\/p>\n<hr width=\"75%\"><\/center><br \/>\n[2011.4.2 \u8ffd\u8a18]<br \/>\n\u7d42\u4e86\u3057\u306a\u3044\u306e\u306f\u5f53\u7136\u3067\u3001\u4e00\u901a\u308a\u306f\u77e5\u308a\u7d42\u308f\u3063\u305f\u5f8c\u306e\u7d42\u4e86\u51e6\u7406\u3092\u3057\u3066\u3044\u306a\u3044\u306e\u3068\u3001<br \/>\nback\u30ad\u30fc\u5951\u6a5f\u306e\u5834\u5408\u306f\u30ad\u30fc\u3092\u62bc\u3057\u305f\u60c5\u5831\u304c\u30a2\u30d7\u30ea\u307e\u3067\u5c4a\u3044\u3066\u3044\u306a\u3044\u305f\u3081\u3067\u3059\u3002(app_glue\u307e\u3067\u306f\u6765\u3066\u308b\u307f\u305f\u3044\u3002)<br \/>\n\u5f8c\u307b\u3069 android_native_app_glue \u3092\u4f7f\u3063\u305f\u5834\u5408\u306b\u3069\u3046\u52d5\u3044\u3066\u3044\u308b\u306e\u304b\u308f\u304b\u3063\u305f\u90e8\u5206\u304b\u3089\u5225\u30a8\u30f3\u30c8\u30ea\u30fc\u3068\u3057\u3066\u3042\u3052\u308b\u4e88\u5b9a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>android-ndk-r5\u304b\u3089NativeActivity\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u8a66\u3057\u306b\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002 NativeActivity\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9 \u3092\u898b\u3064\u3064\u3001\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0(native-activity)\u3092\u524a\u3063\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.ekesete.net\/log\/?p=2701\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-2701","post","type-post","status-publish","format-standard","hentry","category-android"],"_links":{"self":[{"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=\/wp\/v2\/posts\/2701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2701"}],"version-history":[{"count":28,"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=\/wp\/v2\/posts\/2701\/revisions"}],"predecessor-version":[{"id":2827,"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=\/wp\/v2\/posts\/2701\/revisions\/2827"}],"wp:attachment":[{"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ekesete.net\/log\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}