Reputation: 99
When I tried my android application developed in Titanium on galaxy s3 it was just opening for a second and than closing without any error. Realizing that if was fault of "Do not keep activities" under "Developer options", after some researches I anded up here: https://jira.appcelerator.org/browse/TIMOB-12939. If I uncheck "Do not keep activities" everything works fine. Now,I want to make it work though the "Do not keep activity" us checked, in the link above I read that Titanium documentation talks about this, so I ended up here: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Android.Activity. So I changed my code from
if (OS_ANDROID) {
Alloy.createController('home').getView().open(); }
to
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_MAIN,
url:'home.js'
});
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
Ti.Android.currentActivity.startActivity(intent);
thinking that probably I can not use a simple open, like(win.open()) and it crushed because the activity was not declared in manifest. Actually, I did not find a good example on how to work with activities and tiapp.xml, how to add them? So I tried something, probably stupid, in tiapp.xml I added:
<activity android:name=".HomeActivity" url="home.js"/>
and what I get is:
Unable to instantiate activity ComponentInfo{it.trenta.mobile/it.trenta.mobile.HomeActivity}: java.lang.ClassNotFoundException: it.trenta.mobile.HomeActivity
So, how can I declare an activity in Titanum? Is there any way to avoid this checkbox affect your app (apart unchecking it :) )?
Thanks in advance for any help!
Upvotes: 0
Views: 1783
Reputation: 4032
I have created an android activity to use it with an alert dialog so i can close the main activity like this:
var mainActivity = Ti.Android.currentActivity;
$.mainWindow.addEventListener('android:back',function(e){
$.dialog.show();
});
$.dialog.on('click', function(e){
if (e.index == 0){
mainActivity.finish();
}
else
Ti.API.info('You clicked NO');
});
There is also an activity property for UI.Window you can read the documentation to investigate further:
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-activity
also i've had the same problem with my LG Galaxy L5 (the app crashes as soon as i open it) i have resolved this issue using this property called:
navBarHidden : false
and it is referring to this:
On Android, setting this property forces the creation of a heavyweight window. See "Android Heavyweight and Lightweight Windows" in the main description of this class for more information.
Upvotes: 1