Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 31    Views: 226

Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
07/15/13 12:25 PM (12 years ago)

Parse for Android

Hi all, I wondered if anyone has successfully implemented parse to android! If so I'd be grateful for a bit of direction please. All the best Alex
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/15/13 12:37 PM (12 years ago)
Hello I just did this yesterday!
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/15/13 12:37 PM (12 years ago)
Where are you stuck?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/15/13 01:39 PM (12 years ago)
At the beginning! It is very straight forward to implement in iOS, simply add some code with the identifiers into the appdelegate and get the certificates for push enabled. I honestly dont know where to start with Android! Any help would be much appreciated.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/15/13 02:53 PM (12 years ago)
I found this thread very helpful when I learned how to use push with parse. https://www.buzztouch.com/forum/thread.php?tid=F01BB3BDC2215728753B763 A few small things have changed since then, but this should get you 90% of the way there. Alan
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/15/13 02:57 PM (12 years ago)
Download parse android sdk drag the parse-1.3.1.jar file into your libs folder double click that same file and add to build path If your homescreen is a tabs screen then- In your BT_actvity_root tabs.java import- import com.parse.Parse; import com.parse.ParseAnalytics; import com.parse.PushService; add //onCreate @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Parse.initialize(this, "your parse api", "your secret"); PushService.setDefaultPushCallback(this, BT_activity_root_tabs.class); ParseInstallation.getCurrentInstallation().saveInBackground(); ParseAnalytics.trackAppOpened(null); BT_debugger.showIt(activityName + ":onCreate"); Then add this to your androidmanifest.xml just before the </application> <service android:name="com.parse.PushService" /> <receiver android:name="com.parse.ParseBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.USER_PRESENT" /> </intent-filter> </receiver> </application> Then thats about it the code may warn you. let me know if it does. If you have problems let me know I will post how to fix as soon as i get a chance.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/15/13 03:03 PM (12 years ago)
Blinding, thanks to you both, really good of you :)
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/15/13 04:30 PM (12 years ago)
Hi, One Error ParseInstallation cannot be resolved.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/15/13 04:36 PM (12 years ago)
Try to right click on any of the underlined in red words in the BT activity tab . Java. Sometimes it's just an extra import
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/15/13 04:46 PM (12 years ago)
Ok will check thanks
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/15/13 04:55 PM (12 years ago)
Its not a duplication.. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Parse.initialize(this, "VfMqKVDN6AKXzDbjpGZnaNY0rWxMis0xLOMyP0Yi", "CHfBKRXSzI16s3URb6FFJO0kUduSKj9iuAHaGiWL"); PushService.setDefaultPushCallback(this, BT_activity_root_tabs.class); **ParseInstallation.getCurrentInstallation().saveInBackground(); ParseAnalytics.trackAppOpened(null); BT_debugger.showIt(activityName + ":onCreate"); The two ** indicate the line
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/15/13 05:00 PM (12 years ago)
Did you add the jar to build path? Did you make sure there was a line of space in XML file when you added code?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/15/13 05:07 PM (12 years ago)
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/15/13 05:14 PM (12 years ago)
I will have check it out when I get home. Is anything underlined red?
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
07/15/13 05:36 PM (12 years ago)
Alex@TM, Move that code up in your manifest file. LA
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/15/13 05:37 PM (12 years ago)
Are you self hosted? I am, I don't know if that makes a difference.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/16/13 01:12 AM (12 years ago)
Yup, self hosted. ParseInstallation is underlined in red. I'll move the code in .xlm and see if that helps. Cheers
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/16/13 01:22 AM (12 years ago)
Hi Alex, I successfully use a fairly similar approach to @feraco (but there are a couple of differences). I updated an android app yesterday and added parse push and I noticed my 'recipe' needed to be updated. I'm currently re-writing it, bear with me and I'll ping you a copy if you like. Alan
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/16/13 01:51 AM (12 years ago)
Lovely, thanks Alan
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/16/13 03:11 AM (12 years ago)
Hi Alex, My last working version of the parse sdk that 'just worked' in an Android app was 1.1.9. The latest sdk is 1.3.1. I think the most significant difference is that it includes analytic tracking. I have one app working with each, although on the 1.3.1 I can't quite work out why, as my second build failed. Perhaps I could email you my updated recipe and you could try it out? Please send me a message with your email and I'll send it over by return. Cheers, Alan
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/16/13 05:14 AM (12 years ago)
Sure thanks [email protected]
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/16/13 05:47 AM (12 years ago)
It's in the post.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/16/13 06:34 AM (12 years ago)
@feraco Just to let you know I've fixed this with: import com.parse.PushInstallation; No idea why I did not see this before! Thanks to everyone for all the assistance.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/16/13 06:34 AM (12 years ago)
@Alan, thanks for that, i've emailed you. Might be best to follow the recipe in this thread, seems to work :)
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/16/13 09:51 AM (12 years ago)
@feraco's solution works very nicely. I used the 4 lines of code in the src/yourappname/yourappname_appDelegate.java) immediately after super.onCreate() instead of in the BT_actvity_root tabs.java. It is simpler than the previous solution I was using and works with the latest parse SDK (1.3.1 a the the time of writing). How I was doing it before doesn't work with 1.3.1 parse SDK, so this is good timimg. Cheers guys
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/16/13 09:55 AM (12 years ago)
Good to here that I did something right.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/16/13 10:04 AM (12 years ago)
Now does anybody knows how to make a push pop up an alert box in the middle of an Android app?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/16/13 10:59 AM (12 years ago)
Yes @feraco, you did, wonderful solution that is much appreciated. :)
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
07/16/13 12:26 PM (12 years ago)
Alex@TM -Thanks AlanMac - I would also like to know how to make a push pop up an alert box in the middle of an Android app. Have you found any parse documentation?
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/16/13 12:32 PM (12 years ago)
Hi @feraco and thanks again for the tips on this thread - great timing for me! I've found the parse docs, https://parse.com/docs/push_guide#receiving-tracking/Android but I am not good enough at Android to tell if they are much help, although the reference to custom receiver looks promising.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/18/13 01:48 PM (12 years ago)
I have noticed with the the latest parse SDK, that unless I configure the build path with every tickable option ticked, that my app consistently crashes with a 'stopped unexpectedly' message when I start the app. I didn't have to do this before.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/18/13 01:55 PM (12 years ago)
Could this be what is stopping my app on play from loading do you think? https://play.google.com/store/apps/details?id=com.scootfest&hl=en_GB
 

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.