{"id":22857,"date":"2014-03-19T01:00:54","date_gmt":"2014-03-18T23:00:54","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=22857"},"modified":"2014-03-18T21:37:59","modified_gmt":"2014-03-18T19:37:59","slug":"android-app-tutorialpeg-board-game","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html","title":{"rendered":"Android App tutorial:Peg board game"},"content":{"rendered":"<p>I released in <a href=\"https:\/\/github.com\/survivingwithandroid\/Swa-app\/tree\/master\/PegBoardv1\" target=\"_blank\">Github<\/a> the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new version.<\/p>\n<p>The app screenshots are shown below:<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_14.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_14-300x171.png\" alt=\"board_1[4]\" width=\"300\" height=\"171\" class=\"aligncenter size-medium wp-image-23075\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_14-300x171.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_14.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_24.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_24-300x171.png\" alt=\"board_2[4]\" width=\"300\" height=\"171\" class=\"aligncenter size-medium wp-image-23076\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_24-300x171.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_24.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_34.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_34-300x171.png\" alt=\"board_3[4]\" width=\"300\" height=\"171\" class=\"aligncenter size-medium wp-image-23077\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_34-300x171.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_34.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>There are some interesting aspects we can consider in this app and they are described below. It can be used as example how to integrate different elements like <strong>SlidingPaneLayoutfragments<\/strong>, <strong>event handling<\/strong> and so on.<\/p>\n<p><a name=\"more\"><\/a><\/p>\n<h2>App structure<\/h2>\n<p>The main android UI pattern used by the app is the <a href=\"http:\/\/www.survivingwithandroid.com\/2013\/10\/android-slidingpanelayout-tutorial.html\" target=\"_blank\">Sliding Pane layout<\/a> because we need to have the screen divided in two area: the main area is where we can play with our pegs and the other one that usually is closed is the menu.<\/p>\n<p>So the overall layout is:<\/p>\n<pre class=\" brush:xml\">&lt;android.support.v4.widget.SlidingPaneLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:id=\"@+id\/sp\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\" \r\n    android:background=\"@drawable\/tilebkg\"\r\n    &gt;\r\n\r\n    &lt;fragment\r\n        android:id=\"@+id\/pinMenu\"\r\n        android:name=\"com.survivingwithandroid.pegboard.fragment.MenuFragment\"\r\n        android:layout_width=\"200dp\"\r\n        android:layout_height=\"match_parent\"\r\n        android:layout_gravity=\"left\" \r\n        \/&gt;\r\n\r\n    &lt;fragment\r\n        android:id=\"@+id\/pinTable\"\r\n        android:name=\"com.survivingwithandroid.pegboard.fragment.DreamPinTableFragment\"\r\n        android:layout_width=\"600dp\"\r\n        android:layout_height=\"match_parent\"\r\n        android:layout_gravity=\"right\"\r\n        android:layout_weight=\"1\" \/&gt;\r\n\r\n&lt;\/android.support.v4.widget.SlidingPaneLayout&gt;<\/pre>\n<p>The result is shown below:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_2_fragment4.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_2_fragment4-300x171.png\" alt=\"board_2_fragment[4]\" width=\"300\" height=\"171\" class=\"aligncenter size-medium wp-image-23078\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_2_fragment4-300x171.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_2_fragment4.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>As you can notice the SlidingPaneLayout handles two fragments <code>DreamPinTableFragment<\/code> and <code>MenuFragment<\/code>. DreamPinTableFragment takes care of creating the table and handling the user touch so that the user can place pins on it, while the MenuFragment handles the some options like choosing the pin colors, save the work and so on.<\/p>\n<h2>Custom Layout with ViewGroup<\/h2>\n<p>The peg board is implemented as custom layout. The class that implements it is called <code>PinTableView<\/code> that extends <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/ViewGroup.html\" target=\"_blank\">ViewGroup<\/a>. This custom layout takes care of dividing the UI screen in small cells that corresponds to the holes where the pegs are placed. The app screen is treated as a table divided in rows and columns.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The first method called by DreamPinTableFragment is <em>disposePin<\/em>. This method calculates the number or rows and columns and initializes the table:<\/p>\n<pre class=\" brush:java\">public int[] disposePins(int width, int height, int dotSize) {\r\n\r\n    this.dotSize = dotSize;\r\n\r\n    numRow = height \/ dotSize + 1;\r\n    numCol =  width \/ dotSize + 1;\r\n\r\n    int[] dotColors = Pin.createDotArray(dotSize, true);\r\n\r\n    for (int r=0; r &lt; numRow ; r++) {\r\n        for (int c=0; c &lt; numCol; c++) {\r\n            PinImageView pinImg = new PinImageView(getContext(), r, c);\r\n            this.addView(pinImg);               \r\n        }\r\n    }\r\n\r\n    return new int[]{numRow, numCol};\r\n}<\/pre>\n<p>Notice that in this method we add PinImageView (another custom view) to the layout (line\u2026) giving to them the right row and column number.<\/p>\n<p>Then in onLayout method we traverse the list of childs (we added previously) and start placing them in the right position. In this case we need to calculate the x and y coordinates in real pixel, this is simple once we know the row and column number and the cell pixel size:<\/p>\n<pre class=\" brush:java;highlight:[9,11,12,13,14]wrap-lines:false\">@Override\r\nprotected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) {\r\n    int childCount = getChildCount();\r\n\r\n    for (int i=0; i &lt; childCount; i++) {\r\n        PinImageView pinImg = (PinImageView) getChildAt(i);\r\n\r\n        \/\/int left = pinImg.getCol() * dotSize + dotSize * (pinImg.getType() == PinImageView.COLOR_COMMANDS || pinImg.getType() == PinImageView.DELETE ? 0 : 1);\r\n        int left = pinImg.getCol() * dotSize;\r\n        \/\/int top = pinImg.getRow()  * dotSize + dotSize * (pinImg.getType() == PinImageView.COLOR_COMMANDS || pinImg.getType() == PinImageView.DELETE ? 0 : 1);\r\n        int top = pinImg.getRow()  * dotSize;\r\n        int right = left + dotSize ;\r\n        int bottom = top + dotSize ;\r\n\r\n        pinImg.layout(left, top, right, bottom);            \r\n    }\r\n\r\n}<\/pre>\n<p>In this way, we created an empty board that looks like the picture shown below:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_18.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_18-300x171.png\" alt=\"board_1[8]\" width=\"300\" height=\"171\" class=\"aligncenter size-medium wp-image-23079\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_18-300x171.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/board_18.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2>Custom imageView: PinImageView<\/h2>\n<p>As we saw before, we place in our layout a custom ImageView childs. PinImageView is a simple class that extends <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/ImageView.html\" target=\"_blank\">ImageView<\/a> and represents a single Peg (or pin as we prefer to call it). This class has an internal state that holds the type of the peg it represents and implements some kind of animation to make the UI more attractive.<\/p>\n<pre class=\" brush:java\">public class PinImageView extends ImageView  {\r\nprivate int row;\r\nprivate int col;    \r\nprivate int xSize;\r\nprivate int ySize;    \r\nprivate int stato = -1;    \r\nprivate Context ctx;\r\nprivate int currentPinId;\r\n\r\npublic PinImageView(Context context, int row, int col) {\r\n    super(context);\r\n    this.ctx = context;\r\n    this.row = row;\r\n    this.col = col;\r\n    \/\/this.parent = parent;        \r\n\r\n    \/\/ Load image\r\n    Drawable d  = getResources().getDrawable(TableConfig.pinBackground);\r\n    setImageDrawable(d);        \r\n    xSize = this.getWidth();\r\n    ySize = this.getHeight();\r\n    this.currentPinId = TableConfig.pinBackground;\r\n\r\n}\r\n...\r\nclass AnimView implements Runnable {\r\n\r\n        Animation anim;\r\n        Drawable d;\r\n\r\n        public AnimView(Animation anim, Drawable d) {\r\n            this.anim = anim;\r\n            this.d = d;\r\n        }\r\n        @Override\r\n        public void run() {\r\n            anim.setAnimationListener(new Animation.AnimationListener() {\r\n\r\n                @Override\r\n                public void onAnimationStart(Animation animation) {\r\n                    TableConfig.playSound(PinImageView.this.ctx);\r\n                }\r\n\r\n                @Override\r\n                public void onAnimationRepeat(Animation animation) {}\r\n\r\n                @Override\r\n                public void onAnimationEnd(Animation animation) {\r\n                    setImageDrawable(d);\r\n                    PinImageView.this.setVisibility(View.VISIBLE);\r\n                }\r\n            });\r\n\r\n            PinImageView.this.startAnimation(anim);    \r\n        }\r\n\r\n    }\r\n}<\/pre>\n<h2>Handle user touch: OnTouchEvent and OnTouchListener<\/h2>\n<p>The next step is handling the user touch. We define that <code>DreamPinTableFragment<\/code> listens to the events triggered when user touches the screen. We want to place a peg in the position where user touched the screen:<\/p>\n<pre class=\" brush:java\">@Override\r\npublic boolean onTouch(View v, MotionEvent event) {\r\n\r\n    int x = (int) event.getX() ;\r\n    int y = (int) event.getY() ;\r\n\r\n    if (event.getAction() == MotionEvent.ACTION_DOWN) {\r\n        pinsTable.changePinColor(x, y);            \r\n        return true;\r\n    }\r\n    else if (event.getAction() == MotionEvent.ACTION_MOVE) {\r\n        pinsTable.changePinColor(x, y);    \r\n        return true;\r\n    }\r\n\r\n    return false;\r\n\r\n}<\/pre>\n<p>and then we delegate to the PinTableView to handle the event passing the coordinates:<\/p>\n<pre class=\" brush:java\">public void changePinColor(int x, int y) {\r\n    int row = getRow(y);\r\n    int col = getColumn(x);\r\n\r\n    PinImageView pinImg = (PinImageView) getChildAt(col + ( row  * numCol ));\r\n    if (pinImg != null) {\r\n        pinImg.setPinColor(currentColor);    \r\n\r\n    }\r\n}<\/pre>\n<p>Knowing the x and y coordinates we can calculate the corresponding row and column and set the peg with the right color.<\/p>\n<h2>App Menu<\/h2>\n<p>As we explained before the app has a menu where user can select the pincolor, save the work or change the table background. The class that handles the menu is called MenuFragment. This is very simple class, it just notifies to the main activity the events triggered when user selects a menu item. In turn, the main activity handle this event informing the other fragment when these event regards pegs or some actions that have to be taken on the table.<\/p>\n<p>The MenuFragment defines an interface (a listener) that we have to implement when we want to have information on the events occurred in the menu:<\/p>\n<pre class=\" brush:java\">public static interface MenuEventListener {\r\n    public void onPinSelected(int pinId);\r\n    public void onClearSelected();\r\n    public void onSaveSelected();\r\n    public void onBackgroundSelected();\r\n}<\/pre>\n<p>So the main activity:<\/p>\n<pre class=\" brush:java;highlight:[5,10,15,20]\">public class DreamPinsActivity extends Activity implements\r\nMenuFragment.MenuEventListener {\r\n....\r\n    @Override\r\n    public void onPinSelected(int pinId) {\r\n\r\n        pinTableFrag.setCurrentPin(pinId);\r\n        closeMenu();\r\n    }\r\n\r\n    @Override\r\n    public void onClearSelected() {\r\n        ...\r\n    }\r\n\r\n    @Override\r\n    public void onSaveSelected() {\r\n        closeMenu();\r\n        ...\r\n    }\r\n\r\n    public void onBackgroundSelected() {\r\n        ...\r\n    }\r\n}<\/pre>\n<h2>Save layout as image<\/h2>\n<p>The last aspect we want to cover is saving the layout as image. We can implement it in this way:<\/p>\n<p>in the PinsTableView:<\/p>\n<pre class=\" brush:java wrap-lines:false\">public Bitmap createBitmap() {\r\n    Bitmap b = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.RGB_565);        \r\n    Canvas c = new Canvas(b);\r\n\r\n    this.draw(c);\r\n\r\n    return b;\r\n}<\/pre>\n<p>where we create an empty bitmap having the same size of the screen and then draw on the corresponding <a href=\"http:\/\/developer.android.com\/reference\/android\/graphics\/Canvas.html\" target=\"_blank\">Canvas<\/a>. Once we have our bitmap that contains the screenshot of the app screen we save it in a file:<\/p>\n<pre class=\" brush:java\">OutputStream outStream = context.getContentResolver()\r\n        .openOutputStream(uri);\r\n\r\nb.compress(Bitmap.CompressFormat.PNG, 100, outStream);\r\noutStream.flush();\r\noutStream.close();<\/pre>\n<ul>\n<li>Source code availabe @ <a href=\"https:\/\/github.com\/survivingwithandroid\/Swa-app\/tree\/master\/PegBoardv1\" target=\"_blank\">github<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/www.survivingwithandroid.com\/2014\/03\/android-app-tutorial-custom-layout.html\">Android App tutorial:Peg board game<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Francesco Azzola at the <a href=\"http:\/\/www.survivingwithandroid.com\/\">Surviving w\/ Android<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I released in Github the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new version. The app screenshots are shown below: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; There are some interesting aspects we &hellip;<\/p>\n","protected":false},"author":449,"featured_media":46,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-22857","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-games"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android App tutorial:Peg board game<\/title>\n<meta name=\"description\" content=\"I released in Github the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android App tutorial:Peg board game\" \/>\n<meta property=\"og:description\" content=\"I released in Github the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-03-18T23:00:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Francesco Azzola\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Francesco Azzola\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html\"},\"author\":{\"name\":\"Francesco Azzola\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/1b8d9e567a8adf5007f58dc3674856da\"},\"headline\":\"Android App tutorial:Peg board game\",\"datePublished\":\"2014-03-18T23:00:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html\"},\"wordCount\":710,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"articleSection\":[\"Android Games\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html\",\"name\":\"Android App tutorial:Peg board game\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"datePublished\":\"2014-03-18T23:00:54+00:00\",\"description\":\"I released in Github the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/android-app-tutorialpeg-board-game.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Android Games\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\\\/android-games\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Android App tutorial:Peg board game\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/1b8d9e567a8adf5007f58dc3674856da\",\"name\":\"Francesco Azzola\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b8fcfaaab43642cae206ca07965b6b7adce348e00a1b9880392e5801b58cc326?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b8fcfaaab43642cae206ca07965b6b7adce348e00a1b9880392e5801b58cc326?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b8fcfaaab43642cae206ca07965b6b7adce348e00a1b9880392e5801b58cc326?s=96&d=mm&r=g\",\"caption\":\"Francesco Azzola\"},\"description\":\"He's a senior software engineer with more than 15 yrs old experience in JEE architecture. He's SCEA certified (Sun Certified Enterprise Architect), SCWCD, SCJP. He is an android enthusiast and he has worked for long time in the mobile development field.\",\"sameAs\":[\"http:\\\/\\\/www.survivingwithandroid.com\\\/\",\"http:\\\/\\\/it.linkedin.com\\\/in\\\/francescoazzola\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/francesco-azzola\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android App tutorial:Peg board game","description":"I released in Github the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html","og_locale":"en_US","og_type":"article","og_title":"Android App tutorial:Peg board game","og_description":"I released in Github the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new","og_url":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-03-18T23:00:54+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","type":"image\/jpeg"}],"author":"Francesco Azzola","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Francesco Azzola","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html"},"author":{"name":"Francesco Azzola","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/1b8d9e567a8adf5007f58dc3674856da"},"headline":"Android App tutorial:Peg board game","datePublished":"2014-03-18T23:00:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html"},"wordCount":710,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","articleSection":["Android Games"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html","url":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html","name":"Android App tutorial:Peg board game","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","datePublished":"2014-03-18T23:00:54+00:00","description":"I released in Github the source code of an app that can be used to play peg board. This app was published on the market some times ago and this is a new","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/android-app-tutorialpeg-board-game.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/www.javacodegeeks.com\/category\/android"},{"@type":"ListItem","position":3,"name":"Android Games","item":"https:\/\/www.javacodegeeks.com\/category\/android\/android-games"},{"@type":"ListItem","position":4,"name":"Android App tutorial:Peg board game"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/1b8d9e567a8adf5007f58dc3674856da","name":"Francesco Azzola","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b8fcfaaab43642cae206ca07965b6b7adce348e00a1b9880392e5801b58cc326?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b8fcfaaab43642cae206ca07965b6b7adce348e00a1b9880392e5801b58cc326?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b8fcfaaab43642cae206ca07965b6b7adce348e00a1b9880392e5801b58cc326?s=96&d=mm&r=g","caption":"Francesco Azzola"},"description":"He's a senior software engineer with more than 15 yrs old experience in JEE architecture. He's SCEA certified (Sun Certified Enterprise Architect), SCWCD, SCJP. He is an android enthusiast and he has worked for long time in the mobile development field.","sameAs":["http:\/\/www.survivingwithandroid.com\/","http:\/\/it.linkedin.com\/in\/francescoazzola"],"url":"https:\/\/www.javacodegeeks.com\/author\/francesco-azzola"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/22857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/449"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=22857"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/22857\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=22857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=22857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=22857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}