Discussion Forums  >  BT.com Website, Account Questions

Replies: 2    Views: 153

Bing Quan
Aspiring developer
Profile
Posts: 94
Reg: Jun 01, 2011
Singapore
5,340
03/14/12 02:55 AM (13 years ago)

TechJeeper's Xtify Push Notification for BT-server (Android) Guide is Down!

 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
03/14/12 10:49 AM (13 years ago)
This is just a reference guide to how I got Xtify Push SDK for Android working with my BT-Server 2.0 created App. I pulled alot of the Xtify Location information from the code, so it may look slightly different for you. 1. First thing is to create your Xtify account and key (http://console.xtify.com/quick-start) 2. Download the Xtify Android XMPP SDK File (http://developer.xtify.com/display/sdk/Download+the+Xtify+SDKs) 3. Download the Source for your App if you havn't already done so. Make sure you can build it and that it runs fine before starting. 4. Open both your Project Directory and the ACME Xtify Example Folder (Xtify Android SDK Package v.1050samplesAcmeLabs) 5. Copy the Inbox folder Xtify Android SDK Package v.1050samplesAcmeLabssrccomacmelabsinbox to YourProjectsrccomyourproject 6. Copy the XtifyAndroidSDK.jar Xtify Android SDK Package v.1050samplesAcmeLabsjarXtifyAndroidSDK.jar to YourProjectjarXtifyAndroidSDK.jar 6.1. Copy the files from each of the res folders (anim, drawable, ect) **NOT THE VALUES FOLDER** from the AcmeLabsres folder to the corisponding folder in your project directory. 7. Open Eclipse got to File - New Project - Android Project 8. Use Build Target Google APIs for Android 2.3.3, if you don't have it, use the Android SDK Manager under the Help Menu to download and install it. 9. Right click on your project name and go to properties. 10. Click on Java Build Path and Libraries. Make sure XtifyAndroidSDK.jar is in there, if it is not, click Add JARs and navigate to it. 11. In the Properties window, click Java Compiler, make sure Compliance Level 1.6 is selected. 12. Open each of the YourProject/src/com.yourproject.inbox files and change the acmelabs in the fist line to match your project (it will read com.acmelabs.inbox) THE FOLLOWING I COPY/PASTED THE CODE FROM THE ACME SAMPLE FILES, USE THIS AS REFERANCE ONLY, I WOULD FIND THE ACTUAL CODE FROM THE SRC ACME SAMPLE FILES AND COPY THEM INSTEAD 13. Open the YourProject_activity_base.java file in the src folder. 13.1. Locate the line: import org.json.JSONObject; Add this after: import com.xtify.android.sdk.PersistentLocationManager; import android.content.Context; 13.2. Find the line: public class BT_activity_base extends Activity implements LocationListener{ Add this after: private PersistentLocationManager persistentLocationManager; 13.3. Locate this line: public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Add this after: final Context context = this; Thread xtifyThread = new Thread(new Runnable() { @Override public void run() { persistentLocationManager = new PersistentLocationManager( context); // 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 13.4. Try to resolve any Errors and save the _activity_base.java file THE FOLLOWING SECTION IS HOW I IMPLEMENTED AN EXNABLE/DISABLE NOTIFICATION BUTTON ON MY MENULISTSIMPLE MAIN MENU. THIS REQUIRES THE SIMPLE LIST MENU PLUGIN TO BE INSTALLED AND UTILIZED 14. Open yourproject_screen_menuListSimple.java 14.1. Locate this line: import org.json.JSONObject; After this add: import com.yourproject.R; import com.xtify.android.sdk.PersistentLocationManager; 14.2. Locate this line: public class BT_screen_menuListSimple extends BT_activity_base implements OnScrollListener{ After this add: private PersistentLocationManager persistentLocationManager; 14.3. Remove or comment out the code between //options menu (hardware menu-button) and //end options menu 14.4. Save the File. 15. Open yourproject_activity_base.java 15.1. Locate the following: //onDestroy @Override public void onDestroy() { super.onDestroy(); //BT_debugger.showIt(activityName + :onDestroy); } After this add: @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, 0, 0, Disable Notif); menu.add(0, 1, 0, Refresh); menu.add(0, 2, 0, Enable Notif); menu.findItem(0).setIcon(R.drawable.menu_preferences); menu.findItem(1).setIcon(android.R.drawable.ic_menu_revert); menu.findItem(2).setIcon(R.drawable.menu_preferences); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: { persistentLocationManager.setNotificationsDelivery(false); return true; } case 1: { refreshAppData(); return true; } case 2: { persistentLocationManager.setNotificationsDelivery(true); return true; } } return false; } 15.2. Save the file. 16. Open your AndroidManaifest.xml 16.1. The following is how I have my permissions setup, you may need to tweak them to meet your needs, I stripped mine to the minimum for my app to run: <!-- required device permissions --> <uses-permission android:name=android.permission.ACCESS_FINE_LOCATION /> <uses-permission android:name=android.permission.RECEIVE_BOOT_COMPLETED /> <uses-permission android:name=android.permission.READ_PHONE_STATE /> <uses-permission android:name=android.permission.ACCESS_NETWORK_STATE /> <uses-permission android:name=android.permission.INTERNET /> <uses-permission android:name=android.permission.VIBRATE /> <!-- recommneded device features --> <uses-feature android:name=android.hardware.telephony android:required=false/> 16.2. Locate the following: <intent-filter> <action android:name=android.intent.action.MAIN /> <category android:name=android.intent.category.LAUNCHER /> </intent-filter> </activity> Add this after AND **REPLACE YOUR APP_KEY WHERE SPECIFIED (3 PLACES)**: <activity android:name=.CustomDataActivity android:label=Custom Data android:screenOrientation=portrait > <intent-filter> <action android:name=com.aospoics.DISPLAY_CUSTOM_DATA /> <category android:name=android.intent.category.DEFAULT /> <data android:scheme=notif /> </intent-filter> </activity> <activity android:name=com.xtify.android.sdk.SettingsActivity android:label=Settings android:screenOrientation=portrait > </activity> <activity android:name=com.xtify.android.sdk.NotificationDetailsActivity android:label=Notification Details android:excludeFromRecents=true > </activity> <activity android:name=com.xtify.android.sdk.NotificationSettingsActivity android:label=Notification Settings > </activity> <activity android:name=com.aospoics.inbox.NotificationInbox android:label=INBOX android:screenOrientation=portrait> </activity> <service android:name=com.xtify.android.sdk.MainService android:label=Notifications Service > <intent-filter> <action android:name=com.xtify.android.sdk.IMainService /> <category android:name=com.xtify.android.sdk.IMainService /> <category android:name=com.xtify.android.sdk.IMainService.V1050 /> </intent-filter> </service> <receiver android:name=com.aospoics.inbox.NotificationInboxReceiver> <intent-filter android:priority=9999> <action android:name=com.xtify.android.sdk.SHOW_NOTIFICATION /> <!-- KEEP THE FORWARD SLASH IN FRONT OF THE API KEY ON THE LINE BELOW --> <data android:scheme=notif android:host=notification.xtify.com android:pathPrefix=/YOUR_APP_KEY /> </intent-filter> </receiver> <receiver android:name=com.xtify.android.sdk.MainReceiver> <intent-filter> <action android:name=com.xtify.android.sdk.SHOW_NOTIFICATION /> <action android:name=com.xtify.android.sdk.NOTIFICATION_CLICKED /> <action android:name=com.xtify.android.sdk.NOTIFICATION_CLEARED /> <action android:name=com.xtify.android.sdk.SAVE_REGISTERED_CP_ID /> <action android:name=com.xtify.android.sdk.SAVE_USER_KEY /> <!-- MAKE SURE THE API KEY ON THE NEXT LINE IS PRECEDED BY A SLASH --> <data android:scheme=notif android:host=notification.xtify.com android:pathPrefix=/YOUR_APP_KEY /> </intent-filter> <intent-filter> <action android:name=android.intent.action.BOOT_COMPLETED /> <action android:name=android.intent.action.ACTION_POWER_CONNECTED /> <action android:name=com.xtify.android.sdk.SEND_SETTINGS /> </intent-filter> <intent-filter> <action android:name=android.intent.action.PACKAGE_ADDED /> <action android:name=android.intent.action.PACKAGE_REMOVED /> <data android:scheme=package /> </intent-filter> </receiver> <meta-data android:name=XTIFY_SDK_APP_KEY android:value=YOUR_APP_KEY /> 16.3. Save the File 17. Try to run it and see if it works! Let me know if you have any questions or run into any issues, as I said this is ONLY a GUIDE, the code might have been tweaked to meet my needs. Anywhere you see aospoics you need to change to your app name.
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
03/14/12 10:50 AM (13 years ago)
I think this is the guide you were looking for.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.