{"_id":"55781fe45129590d003ff510","parentDoc":null,"project":"54aa7f773b56130b0056c86e","category":{"_id":"55781fe35129590d003ff4fc","pages":["55781fe45129590d003ff50d","55781fe45129590d003ff50e","55781fe45129590d003ff50f","55781fe45129590d003ff510","55781fe45129590d003ff511","55781fe45129590d003ff512","55781fe45129590d003ff513","55781fe45129590d003ff514","55781fe45129590d003ff515","55781fe45129590d003ff516","55f692b4fe4cce21005c78b0","55f7e91e60cc850d008a7a45","56333cab9c607719001b85e4","564462ed9ce94c0d00068ce9","564f54fa48a1df1700836653","565ee9e7413e06170093dde0","5661a8fdb401c70d00dde6fa","5671348860c8e70d006c96a1","568ce9707d3bf02300aa7734"],"version":"55781fe25129590d003ff4f7","__v":10,"project":"54aa7f773b56130b0056c86e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:44:00.338Z","from_sync":false,"order":4,"slug":"android-sdk","title":"Android SDK"},"user":"54aa7f3f9bb00c0b00cb899b","githubsync":"","version":{"_id":"55781fe25129590d003ff4f7","project":"54aa7f773b56130b0056c86e","forked_from":"54aa7f773b56130b0056c871","__v":6,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z","categories":["55781fe35129590d003ff4f8","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","55781fe35129590d003ff4fb","55781fe35129590d003ff4fc","55781fe35129590d003ff4fd","55781fe35129590d003ff4fe","564bbc7e8841060d00abb2ee","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","582318b23b961a0f009516a1","594a848c9f4771001a43c959"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Developers","version_clean":"2.0.0","version":"2.0"},"__v":19,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-01-05T14:11:18.293Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Pulsate Factory\"\n}\n[/block]\nIn order to instantiate the Pulsate Manager you need to use the PulsateFactory. It creates and holds the Pulsate Manager instance, making sure there's only one per application.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" IPulsateManager manager = PulsateFactory.getInstance();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nWe recommend to create a method in your App class which will hold the instance and create one if it doesnt exist.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Initialize IPulsateManager\",\n  \"body\": \"Please remember to initialize the IPulsateManager in your application \\\"onCreate()\\\" method.\\nTo initilize use - PulsateFactory.getInstance();\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public class MyApplication extends Application {\\n\\n    IPulsateManager manager;\\n\\n    :::at:::Override\\n    public void onCreate() {\\n        super.onCreate();\\n      \\tPulsate.install(this);\\n\\t\\t\\t\\tgetPulsate();\\n    }\\n\\n    public IPulsateManager getPulsate() {\\n        if (manager == null)\\n            manager = PulsateFactory.getInstance();\\n        return manager;\\n    }\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"With the release of 2.10.0 PulsateApp has been deprecated. Please use Pulsate.install(this); in your Application's onCreate method to properly install Pulsate.\",\n  \"title\": \"PulsateApp\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Starting Pulsate\"\n}\n[/block]\nThe Pulsate Manager will start the session lifecycle, beacon ranging and geofencing once after you call *startPulsate* on the manager. IPulsateRequestListener can be null.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"manager.startPulsateSession(new IPulsateRequestListener() {\\n  @Override\\n  public void onSucess() {\\n  }\\n\\n  @Override\\n  public void onError(Throwable e) {\\n  }\\n});\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nIf you keep the manager in your application class as presented above, you have easy access to the manager from anywhere in your app and you can easily start Pulsate.\n\nExamples:\n\n1. If you want to start Pulsate on a specific activity, for example in *\"MainMenuActivity\"*, you should add *\"startPulsateSession()\"* in the *\"onCreate()\"* method of your Activity class.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public class MainMenuActivity extends Activity {\\n    @Override\\n    protected void onCreate(Bundle savedInstanceState) {\\n        super.onCreate(savedInstanceState);\\n        setContentView(R.layout.activity_main_menu);\\n        ((MyApplication) getApplication()).getPulsate().startPulsateSession(...);\\n    }\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n2. If you want to start Pulsate on a specific action, for example on button click, you should add *\"startPulsateSession()\"* after that action happens, in our case we will add *\"startPulsateSession()\"*  in the the *\"onClick()\"* method of our *\"OnClickListener\"*.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Button myButton = (Button) findViewById(R.id.my_button);\\nmyButton.setOnClickListener(new View.OnClickListener() {\\n    @Override\\n    public void onClick(View view) {\\n        ((MyApplication) getApplication()).getPulsate().startPulsateSession(...);\\n    }\\n});\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Starting Pulsate\",\n  \"body\": \"Starting Pulsate in the *\\\"onCreate()\\\"* method of your Application class is not supported.\\nPulsate requires an active activity to start.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Starting Pulsate with Beacon Ranging Disabled\"\n}\n[/block]\nWith the release of version 2.1.1 of the Pulsate SDK you can also start Pulsate with beacon ranging disabled.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Use *\\\"startPulsateSessionWithBeaconsDisabled\\\"* instead of *\\\"startPulsateSession\\\"*.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"manager.startPulsateSessionWithBeaconsDisabled(...);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Starting Pulsate with Location Disabled\"\n}\n[/block]\nWith the release of version 2.7.10 of the Pulsate SDK you can also enable or disable location.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"manager.setGpsManagerEnabled(boolean enabled);\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"running-the-pulsate-sdk-android","type":"basic","title":"Running the Pulsate SDK"}

Running the Pulsate SDK


[block:api-header] { "type": "basic", "title": "Pulsate Factory" } [/block] In order to instantiate the Pulsate Manager you need to use the PulsateFactory. It creates and holds the Pulsate Manager instance, making sure there's only one per application. [block:code] { "codes": [ { "code": " IPulsateManager manager = PulsateFactory.getInstance();", "language": "java" } ] } [/block] We recommend to create a method in your App class which will hold the instance and create one if it doesnt exist. [block:callout] { "type": "danger", "title": "Initialize IPulsateManager", "body": "Please remember to initialize the IPulsateManager in your application \"onCreate()\" method.\nTo initilize use - PulsateFactory.getInstance();" } [/block] [block:code] { "codes": [ { "code": "public class MyApplication extends Application {\n\n IPulsateManager manager;\n\n @Override\n public void onCreate() {\n super.onCreate();\n \tPulsate.install(this);\n\t\t\t\tgetPulsate();\n }\n\n public IPulsateManager getPulsate() {\n if (manager == null)\n manager = PulsateFactory.getInstance();\n return manager;\n }\n}", "language": "java" } ] } [/block] [block:callout] { "type": "danger", "body": "With the release of 2.10.0 PulsateApp has been deprecated. Please use Pulsate.install(this); in your Application's onCreate method to properly install Pulsate.", "title": "PulsateApp" } [/block] [block:api-header] { "type": "basic", "title": "Starting Pulsate" } [/block] The Pulsate Manager will start the session lifecycle, beacon ranging and geofencing once after you call *startPulsate* on the manager. IPulsateRequestListener can be null. [block:code] { "codes": [ { "code": "manager.startPulsateSession(new IPulsateRequestListener() {\n @Override\n public void onSucess() {\n }\n\n @Override\n public void onError(Throwable e) {\n }\n});", "language": "java" } ] } [/block] If you keep the manager in your application class as presented above, you have easy access to the manager from anywhere in your app and you can easily start Pulsate. Examples: 1. If you want to start Pulsate on a specific activity, for example in *"MainMenuActivity"*, you should add *"startPulsateSession()"* in the *"onCreate()"* method of your Activity class. [block:code] { "codes": [ { "code": "public class MainMenuActivity extends Activity {\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main_menu);\n ((MyApplication) getApplication()).getPulsate().startPulsateSession(...);\n }\n}", "language": "java" } ] } [/block] 2. If you want to start Pulsate on a specific action, for example on button click, you should add *"startPulsateSession()"* after that action happens, in our case we will add *"startPulsateSession()"* in the the *"onClick()"* method of our *"OnClickListener"*. [block:code] { "codes": [ { "code": "Button myButton = (Button) findViewById(R.id.my_button);\nmyButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View view) {\n ((MyApplication) getApplication()).getPulsate().startPulsateSession(...);\n }\n});", "language": "java" } ] } [/block] [block:callout] { "type": "danger", "title": "Starting Pulsate", "body": "Starting Pulsate in the *\"onCreate()\"* method of your Application class is not supported.\nPulsate requires an active activity to start." } [/block] [block:api-header] { "type": "basic", "title": "Starting Pulsate with Beacon Ranging Disabled" } [/block] With the release of version 2.1.1 of the Pulsate SDK you can also start Pulsate with beacon ranging disabled. [block:callout] { "type": "warning", "body": "Use *\"startPulsateSessionWithBeaconsDisabled\"* instead of *\"startPulsateSession\"*." } [/block] [block:code] { "codes": [ { "code": "manager.startPulsateSessionWithBeaconsDisabled(...);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Starting Pulsate with Location Disabled" } [/block] With the release of version 2.7.10 of the Pulsate SDK you can also enable or disable location. [block:code] { "codes": [ { "code": "manager.setGpsManagerEnabled(boolean enabled);", "language": "text" } ] } [/block]