0

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!

Aleksandar Milicevic
  • 3,837
  • 1
  • 13
  • 17
linnal
  • 99
  • 1
  • 10

1 Answers1

1

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.

Mario Galván
  • 3,964
  • 6
  • 29
  • 39
  • I set navBar to false and add the code above , but it doesn't change anything. Actually it doesn't crash it just closes, because it thinks that the closed activity it's no needed anymore, so it destroys it. I understand this one, what I don't understand is why it closes the whole app. In alloy, when you open the app the first thing you see is the window with the default image of alloy, then it opens the window in index.js and I think because of the first screen that get's left behind once the index.js opens "Do not keep activities" starts doing his job. Any idea? – linnal Sep 04 '13 at 07:54
  • Yes it does not crash it just closes, have you tried using modal windows? `modal:true` all of the other titanium apps that i have tried in my Galaxy L5 are closed if i don't have this property in my windows – Mario Galván Sep 04 '13 at 15:15