Context context = this;
persistentLocationManager = new PersistentLocationManager(context);
Thread xtifyThread = new Thread(new Runnable() {
@Override
public void run() {
persistentLocationManager.setNotificationIcon(R.drawable.notification);
persistentLocationManager.setNotificationDetailsIcon(R.drawable.icon);
boolean trackLocation = persistentLocationManager.isTrackingLocation();
boolean deliverNotifications = persistentLocationManager.isDeliveringNotifications();
if (trackLocation || deliverNotifications) {
persistentLocationManager.startService();
}
}
});
xtifyThread.start(); // to avoid Android's application-not-responding dialog box,
do non-essential work in another thread
This code also defines the notification icon and the logo that appear on the notification details screen, though that is not mandatory. The image specifications are described in the javadoc documentation.
The main Activity also contains a menu that allows the user to modify the SDK settings. This screen is displayed from the menu item using:
persistentLocationManager.showSettingsActivity(context, false);
Step 5. Include Jar file
The 'XtifyAndroidSDK.jar' file is placed in the 'jar/' directory of your project and added to the classpath. In Eclipse, this can be accomplished by clicking Project Properties > Java Build path > Libraries > Add JARs.
Step 6: Emulator Configuration
When using the emulator, the SDK tries to access the device location. The emulator will show a 'Force close' dialog box unless you enable cell tower-based locations by checking the 'Use wireless networks' checkbox in Settings > Security & location.
Step 7: Displaying Custom Activity without Broadcast Receiver
If you do not use the broadcast receiver, then you cannot use the data associated with the notification, such as Notification Title and Notification Details. You will be able only to display your Custom Activity. If you need the notification data, then use a broadcast receiver. See Step 9 for instructions.
a. To display a custom activity when the mobile user clicks on a notification, add the code below to the AndroidManifest.xml file and remember to change the activity name to your custom activity name.
<activity android:name=".CustomDataActivity" android:label="Custom Data"android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.acmelabs.DISPLAY_CUSTOM_DATA" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="notif" />
</intent-filter>
</activity>
b. The next step is to make the action intent in the website or the web service as your custom intent name. For example:
Action Intent: com.acmelabs.DISPLAY_CUSTOM_DATA
c. Un-check the “Show Notifications Screen” button on the Xtify Console interface, at the Action Type/Advanced tab.