{"__v":58,"_id":"5433300867f20a080097a04b","category":{"__v":22,"_id":"542998547a6b690800768072","pages":["542a3de5e677b0080050898f","544e8298de6bac1000236fe9","542998547a6b690800768074","542ab90154d88d140075fbd4","5433300867f20a080097a04b","5433302067f20a080097a04d","544e7ae6de6bac1000236fb5","54330b4990d63b1c0030c129","543da24b31ca981a00a6ffe7","54333238a807e208003e72d2","544e8305bd51b9080037f9cb","54332b234aeeef0800410a73","5433306067f20a080097a051","543db19f31ca981a00a70053","543d31d6a10ab32000b3aa70","54a1f0af50465f1f00bfa3e8","54cfc5925ff7e617002bbda5","54f4f09158e9df0d00917b3e"],"project":"542998547a6b69080076806e","version":"542998547a6b690800768071","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-09-29T17:35:16.267Z","from_sync":false,"order":0,"slug":"getting-started","title":"Getting Started"},"is_link":false,"parentDoc":null,"project":"542998547a6b69080076806e","user":"542998207a6b690800768069","version":{"__v":9,"_id":"542998547a6b690800768071","project":"542998547a6b69080076806e","createdAt":"2014-09-29T17:35:16.249Z","releaseDate":"2014-09-29T17:35:16.249Z","categories":["542998547a6b690800768072","5433027990d63b1c0030c0f1","5433028190d63b1c0030c0f2","5433028d9a2b451a00ad4508","5433055790d63b1c0030c10a","5461417d37e5bc200049e1e4","54624066ddd31b0800a58db4","54625de66d1f1010002f3901","54d309955616470d0013cc55"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["5436b803d0ffee0e00f19098","5446e0a0beb6320800da6e91","5449f5ca778b3e08002b2267","5449f82227b7fc140078da38","5449faf227b7fc140078da39","5449fbf5778b3e08002b2269","57e1336e9ff1e21900a721dc"],"next":{"pages":[],"description":""},"createdAt":"2014-10-07T00:12:56.692Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":4,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Create a Publisher Account\"\n}\n[/block]\nA Publisher Account is required to use your application, website or game with SuperRewards.\n\nIf you have not already done so, register for a Publisher Account at [pub.superrewards.com](https://pub.superrewards.com/signup).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Our Android SDK\"\n}\n[/block]\nOur Android SDK allows you to present an offer wall whenever it is appropriate in your native app, receive notifications of user transactions, and more. Using the offer wall in your app involves three steps:\n\n1. [Install our SDK](#header-install)\n2. [Display the offer wall to a user](#header-display)\n3. [Get notified of new points available](#header-notification)\n\nThere are also notes below about how to:\n* [Test it out](#header-test)\n* [Get paid](#header-paid)\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"How about a demo?\",\n  \"body\": \"[https://github.com/Playerize/AndroidSDKDemo](https://github.com/Playerize/AndroidSDKDemo)\\n\\nA small Android project including documentation is available!\\nThis demo application simply displays two buttons: pressing the top button will open up the offer wall, pressing the lower button will retrieve the user's points.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Requirements\"\n}\n[/block]\nA few things you need to ensure before you start:\n* Android SDK minimum version 8 (Froyo 2.2)\n* Minimum hardware requirement is ARMV7\n* Java JDK 1.6 or greater\n* The following manifest permissions added to your manifest:\n```\n<uses-permission android:name=\"android.permission.INTERNET\"/>\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>\n<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>\n```\nHere's a [gist snippet of a manifest file](https://gist.github.com/jmagnuss/f70da5dbf12f9657a841) with these permissions added.\n[block:html]\n{\n  \"html\": \"You will need to set up your app in your Dashboard, to get started <a class=\\\"btn btn-primary\\\" role=\\\"button\\\" href='https://pub.superrewards.com/signup'>Sign up</a> or <a href='https://pub.superrewards.com/login'>Log in</a>.\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<a name='header-install'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Install our SDK\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"The screenshots and steps here are for Android Studio.  If you are using Eclipse IDE for your application development you may experience slight differences.  Use the Contact links to the left if you need a hand!\",\n  \"title\": \"Eclipse IDE or Android Studio?\"\n}\n[/block]\n1. Download the [zip file of our Android SDK](http://files.superrewards.com/SDKs/android/SuperRewards-3.1b.jar.zip), and unzip it.\n2. Add the Super Rewards jar file to your project, by copying it into your project’s `libs` folder.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8isrG7CoTKHPLA8FJZtq_Screenshot%202015-04-28%2012.10.53.png\",\n        \"Screenshot 2015-04-28 12.10.53.png\",\n        \"832\",\n        \"195\",\n        \"#1a50a1\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIf using Android Studio, add the JAR file as a 'File dependency' under File->Project Structure:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/I06AIowQgGdd8UZTtmGL_Screenshot%202015-04-28%2012.12.33.png\",\n        \"Screenshot 2015-04-28 12.12.33.png\",\n        \"1053\",\n        \"458\",\n        \"#0e52b5\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n3. In your app’s main activity, add the following imports:\n```\nimport com.playerize.superrewards.SuperRewards;\nimport com.playerize.superrewards.SRUserPoints;\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/EK2cLq1mSDG60nF9dBxB_Screenshot%202015-04-28%2012.46.23.png\",\n        \"Screenshot 2015-04-28 12.46.23.png\",\n        \"451\",\n        \"210\",\n        \"#51609a\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n4. Add our Activity to your AndroidManifest.xml:\n```    \n\t<activity\n            android:name=\"com.playerize.superrewards.activities.SRWebViewActivity\" \n            android:screenOrientation=\"portrait\"\n        />\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Img2aeXVSECyk383yN0U_Screenshot%202015-05-01%2012.21.51.png\",\n        \"Screenshot 2015-05-01 12.21.51.png\",\n        \"599\",\n        \"299\",\n        \"#5c84b6\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<a name='header-display'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Display the Offer Wall to a user\"\n}\n[/block]\nTo bring up the SuperRewards offer wall:\n1. Instantiate a `SuperRewards` object with your application resources and app package name\n2. Show the wall by calling `showOffers` with \n    * your current activity\n    * your app hash, which you can find in your [Dashboard](https://pub.superrewards.com). For more info see [Foundation: Hashes and Keys](doc:foundation-app-hashes-keys-and-signing).\n    * a user ID, which should be a unique ID for the user.  It can be either numeric or text, but must be passed as a String variable.  Check out our [Notes on UIDs](doc:notes-on-uids).\n\n```\nString userId = \"9001234\";\nString appHash = \"nhhpuxlrfgi.022815956434\";\nSuperRewards sr = new SuperRewards(getResources(), \"com.playerize.awesomeapp\");\nsr.showOffers(MainActivity.this, appId, userId);\n```\n[block:html]\n{\n  \"html\": \"To get your app hash and try it out, <a class=\\\"btn btn-primary\\\" role=\\\"button\\\" href='https://pub.superrewards.com/signup'>Sign up</a> or <a href='https://pub.superrewards.com/login'>Log in</a>.\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<a name='header-notification'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Get notified of transactions\"\n}\n[/block]\nWhenever your app wants to check for new completed transactions, it should use the `SRUserPoints` object:\n\nInstantiate the `SRUserPoints` object, passing your application context.  Then you can call the method `updatePoints(String appId, String userId)` on that object, which returns a `boolean` to indicate success or failure:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SRUserPoints userPoints = new SRUserPoints(getApplicationContext());\\nif (userPoints.updatePoints(appId, userId) != false) {\\n  int newpoints = userPoints.getNewPoints();\\n  int totalpoints = userPoints.getTotalPoints();\\n  Toast.makeText(getApplicationContext(), \\\"\\\\tPoint Totals\\\\n New: \\\" + newpoints + \\\" Total: \\\" + totalpoints, Toast.LENGTH_LONG).show(); \\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n* `appId` here is your app hash.  For more info see [Foundation: Hashes and Keys](doc:foundation-app-hashes-keys-and-signing).\n* `userId` here is the same user identifier that you used when you showed the offer wall.\nAfter a successful update, the userPoints object has two member methods, `getNewPoints()` and `getTotalPoints()`. Both methods return integers. totalPoints is the user's accumulated points balance and earnedPoints is the points rewarded since the last query.\n\nWith version 3.1b of the Super Rewards Android SDK, your app can receive points updates automatically. You will need to set up a custom BroadcastReceiver subclass, which is detailed in the demo application available [here](http://files.superrewards.com/SDKs/android/playerize_android_sdk_test-3.1b.zip)\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Asynchronous calls\",\n  \"body\": \"`updatePoints` runs on an asynchronous background thread, and may return `false` depending on the user’s device and network connectivity at the time.\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<a name='header-test'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. Test it out\"\n}\n[/block]\nComing soon: we will make it possible to fire notifications to your app, to test the full process.\n[block:html]\n{\n  \"html\": \"<a name='header-paid'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"5. Get Paid\"\n}\n[/block]\nCheck your earnings in real-time in your [Dashboard](https://pub.superrewards.com).  We do payouts every two weeks, and our fees are the best around, check out the details in [Basics: Getting Paid](doc:basics-getting-paid).\n[block:html]\n{\n  \"html\": \"Enter your banking information in your <a href='https://pub.superrewards.com/account'>Dashboard</a>, or  <a class=\\\"btn btn-primary\\\" role=\\\"button\\\" href='https://pub.superrewards.com/signup'>Sign up</a>.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"6. Updates and Changes\"\n}\n[/block]\n22Apr2015 - 3.1b\n* SDK now does automatic polling for user points\n* Updated sample app, available [here](http://files.superrewards.com/SDKs/android/playerize_android_sdk_test-3.1b.zip)\n\n\n23Mar2015 - 3.0b \n* updated to take advantage of the new Super Rewards offer wall\n* better filtering of offers based on device capabilities\n* viewing offer detail then moving to completing an offer takes the user out to Chrome or other external web browser. Note: please ensure your app is set up to handle exiting to an external app to provide the best user experience.\n* [Download 3.0b] (http://files.superrewards.com/SDKs/android/SuperRewards-3.0b.jar.zip)","excerpt":"Offer walls on Android","slug":"getting-started-android","type":"basic","title":"Getting Started - Android"}

Getting Started - Android

Offer walls on Android

[block:api-header] { "type": "basic", "title": "Create a Publisher Account" } [/block] A Publisher Account is required to use your application, website or game with SuperRewards. If you have not already done so, register for a Publisher Account at [pub.superrewards.com](https://pub.superrewards.com/signup). [block:api-header] { "type": "basic", "title": "Our Android SDK" } [/block] Our Android SDK allows you to present an offer wall whenever it is appropriate in your native app, receive notifications of user transactions, and more. Using the offer wall in your app involves three steps: 1. [Install our SDK](#header-install) 2. [Display the offer wall to a user](#header-display) 3. [Get notified of new points available](#header-notification) There are also notes below about how to: * [Test it out](#header-test) * [Get paid](#header-paid) [block:callout] { "type": "success", "title": "How about a demo?", "body": "[https://github.com/Playerize/AndroidSDKDemo](https://github.com/Playerize/AndroidSDKDemo)\n\nA small Android project including documentation is available!\nThis demo application simply displays two buttons: pressing the top button will open up the offer wall, pressing the lower button will retrieve the user's points." } [/block] [block:api-header] { "type": "basic", "title": "Requirements" } [/block] A few things you need to ensure before you start: * Android SDK minimum version 8 (Froyo 2.2) * Minimum hardware requirement is ARMV7 * Java JDK 1.6 or greater * The following manifest permissions added to your manifest: ``` <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> ``` Here's a [gist snippet of a manifest file](https://gist.github.com/jmagnuss/f70da5dbf12f9657a841) with these permissions added. [block:html] { "html": "You will need to set up your app in your Dashboard, to get started <a class=\"btn btn-primary\" role=\"button\" href='https://pub.superrewards.com/signup'>Sign up</a> or <a href='https://pub.superrewards.com/login'>Log in</a>." } [/block] [block:html] { "html": "<a name='header-install'></a>" } [/block] [block:api-header] { "type": "basic", "title": "1. Install our SDK" } [/block] [block:callout] { "type": "warning", "body": "The screenshots and steps here are for Android Studio. If you are using Eclipse IDE for your application development you may experience slight differences. Use the Contact links to the left if you need a hand!", "title": "Eclipse IDE or Android Studio?" } [/block] 1. Download the [zip file of our Android SDK](http://files.superrewards.com/SDKs/android/SuperRewards-3.1b.jar.zip), and unzip it. 2. Add the Super Rewards jar file to your project, by copying it into your project’s `libs` folder. [block:image] { "images": [ { "image": [ "https://files.readme.io/8isrG7CoTKHPLA8FJZtq_Screenshot%202015-04-28%2012.10.53.png", "Screenshot 2015-04-28 12.10.53.png", "832", "195", "#1a50a1", "" ] } ] } [/block] If using Android Studio, add the JAR file as a 'File dependency' under File->Project Structure: [block:image] { "images": [ { "image": [ "https://files.readme.io/I06AIowQgGdd8UZTtmGL_Screenshot%202015-04-28%2012.12.33.png", "Screenshot 2015-04-28 12.12.33.png", "1053", "458", "#0e52b5", "" ] } ] } [/block] 3. In your app’s main activity, add the following imports: ``` import com.playerize.superrewards.SuperRewards; import com.playerize.superrewards.SRUserPoints; ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/EK2cLq1mSDG60nF9dBxB_Screenshot%202015-04-28%2012.46.23.png", "Screenshot 2015-04-28 12.46.23.png", "451", "210", "#51609a", "" ] } ] } [/block] 4. Add our Activity to your AndroidManifest.xml: ``` <activity android:name="com.playerize.superrewards.activities.SRWebViewActivity" android:screenOrientation="portrait" /> ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/Img2aeXVSECyk383yN0U_Screenshot%202015-05-01%2012.21.51.png", "Screenshot 2015-05-01 12.21.51.png", "599", "299", "#5c84b6", "" ] } ] } [/block] [block:html] { "html": "<a name='header-display'></a>" } [/block] [block:api-header] { "type": "basic", "title": "2. Display the Offer Wall to a user" } [/block] To bring up the SuperRewards offer wall: 1. Instantiate a `SuperRewards` object with your application resources and app package name 2. Show the wall by calling `showOffers` with * your current activity * your app hash, which you can find in your [Dashboard](https://pub.superrewards.com). For more info see [Foundation: Hashes and Keys](doc:foundation-app-hashes-keys-and-signing). * a user ID, which should be a unique ID for the user. It can be either numeric or text, but must be passed as a String variable. Check out our [Notes on UIDs](doc:notes-on-uids). ``` String userId = "9001234"; String appHash = "nhhpuxlrfgi.022815956434"; SuperRewards sr = new SuperRewards(getResources(), "com.playerize.awesomeapp"); sr.showOffers(MainActivity.this, appId, userId); ``` [block:html] { "html": "To get your app hash and try it out, <a class=\"btn btn-primary\" role=\"button\" href='https://pub.superrewards.com/signup'>Sign up</a> or <a href='https://pub.superrewards.com/login'>Log in</a>." } [/block] [block:html] { "html": "<a name='header-notification'></a>" } [/block] [block:api-header] { "type": "basic", "title": "3. Get notified of transactions" } [/block] Whenever your app wants to check for new completed transactions, it should use the `SRUserPoints` object: Instantiate the `SRUserPoints` object, passing your application context. Then you can call the method `updatePoints(String appId, String userId)` on that object, which returns a `boolean` to indicate success or failure: [block:code] { "codes": [ { "code": "SRUserPoints userPoints = new SRUserPoints(getApplicationContext());\nif (userPoints.updatePoints(appId, userId) != false) {\n int newpoints = userPoints.getNewPoints();\n int totalpoints = userPoints.getTotalPoints();\n Toast.makeText(getApplicationContext(), \"\\tPoint Totals\\n New: \" + newpoints + \" Total: \" + totalpoints, Toast.LENGTH_LONG).show(); \n}", "language": "objectivec" } ] } [/block] * `appId` here is your app hash. For more info see [Foundation: Hashes and Keys](doc:foundation-app-hashes-keys-and-signing). * `userId` here is the same user identifier that you used when you showed the offer wall. After a successful update, the userPoints object has two member methods, `getNewPoints()` and `getTotalPoints()`. Both methods return integers. totalPoints is the user's accumulated points balance and earnedPoints is the points rewarded since the last query. With version 3.1b of the Super Rewards Android SDK, your app can receive points updates automatically. You will need to set up a custom BroadcastReceiver subclass, which is detailed in the demo application available [here](http://files.superrewards.com/SDKs/android/playerize_android_sdk_test-3.1b.zip) [block:callout] { "type": "danger", "title": "Asynchronous calls", "body": "`updatePoints` runs on an asynchronous background thread, and may return `false` depending on the user’s device and network connectivity at the time." } [/block] [block:html] { "html": "<a name='header-test'></a>" } [/block] [block:api-header] { "type": "basic", "title": "4. Test it out" } [/block] Coming soon: we will make it possible to fire notifications to your app, to test the full process. [block:html] { "html": "<a name='header-paid'></a>" } [/block] [block:api-header] { "type": "basic", "title": "5. Get Paid" } [/block] Check your earnings in real-time in your [Dashboard](https://pub.superrewards.com). We do payouts every two weeks, and our fees are the best around, check out the details in [Basics: Getting Paid](doc:basics-getting-paid). [block:html] { "html": "Enter your banking information in your <a href='https://pub.superrewards.com/account'>Dashboard</a>, or <a class=\"btn btn-primary\" role=\"button\" href='https://pub.superrewards.com/signup'>Sign up</a>." } [/block] [block:api-header] { "type": "basic", "title": "6. Updates and Changes" } [/block] 22Apr2015 - 3.1b * SDK now does automatic polling for user points * Updated sample app, available [here](http://files.superrewards.com/SDKs/android/playerize_android_sdk_test-3.1b.zip) 23Mar2015 - 3.0b * updated to take advantage of the new Super Rewards offer wall * better filtering of offers based on device capabilities * viewing offer detail then moving to completing an offer takes the user out to Chrome or other external web browser. Note: please ensure your app is set up to handle exiting to an external app to provide the best user experience. * [Download 3.0b] (http://files.superrewards.com/SDKs/android/SuperRewards-3.0b.jar.zip)