clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

Activities started from somewhere other than the launcher fail. #54

Closed amatus closed 10 years ago

amatus commented 11 years ago

I'm starting a neko activity from an android.accounts.AbstractAccountAuthenticator which fails if I haven't already run the main activity because neko hasn't been initialized. My solution was to modify the SplashActivity to start any activity I pass to it and start my authenticator_activity that way. See https://github.com/amatus/CardDAV-Sync.

amatus commented 11 years ago

Specifically: https://github.com/amatus/CardDAV-Sync/commit/cae13d7a7968eb7fca68a6d4f7b4da7adf1f24f7

alexander-yakushev commented 11 years ago

Right, I have not thought of that...

That is not intent abuse, of course, application should be able to be started from any point. Previously neko was initialized from Application.onCreate, which required Clojure to be loaded instantly as application started. I had to move that into SplashActivity to delay Clojure loading.

You could have gone easier way by calling neko.application/init-application at the beginning of your activity. Although you'd have to make sure that it is called only once (since it also starts nrepl, and it would throw an exception if started twice).

I have to think how to deal with this problem sensibly. Meanwhile, thank you for reporting it.

alexander-yakushev commented 11 years ago

So I've just pushed neko 3.0.0-beta6 to be used together with lein-droid 0.2.0-beta3 which should fix your issue. What I changed is I force init-application at onCreate of every activity (defined with defactivity) but make sure that initialization only happens once.

Can you please try it out and say if it works for you?

alexander-yakushev commented 11 years ago

Hey @amatus , have you tried the newest version yet? I hope now it must be fine!

amatus commented 11 years ago

I haven't tried it yet, thanks for reminding me.

amatus commented 10 years ago

This seems to be always starting the package.MAIN activity instead of the activity I was trying to start.

amatus commented 10 years ago

My mistake, stand by...

amatus commented 10 years ago

Confirmed!

alexander-yakushev commented 10 years ago

Thank you, David!