如何使用钛App更快地使我的Android应用程序

时间:2016-01-21 06:12:18

标签: titanium titanium-mobile titanium-alloy titanium-android

我注意到当我使用钛合金在Android设备中部署App时,它工作缓慢,看起来像Android应用程序需要时间在触摸和点击后重定向到下一页。在我之后的3或4秒内转到下一页点击任何UI元素(按钮,视图,标签,图像)

另一方面,它与IOS设备(iphone和ipad)完美配合

我不知道究竟应该是什么问题android.I还重置我的工厂数据在Android和测试应用程序再次但仍然问题到达

这是Android触控/点击问题吗?

请反馈我的问题并告诉我你如何解决它的建议。提前致谢

3 个答案:

答案 0 :(得分:1)

您的问题不是设备,但可能是您登录的API。我建议你插入一个指示器来弥补等待时间,如下所示:

----index.xml----
<Alloy>
    <Window class="login_container" height="auto" horizontalWrap="true">
    <ActivityIndicator id="activityIndicator" message="Wait please..."/>

---- ---- index.js

function login(e) {  
var uname = $.username.value.split(' ').join('');
var pwd = $.password.value.split(' ').join('');

if(uname == ""){
    alert("Enter username.");
    return false;
}
if(pwd == ""){
    alert("Enter password.");
    return false;
}

$.activityIndicator.show();

在更改控制器之前添加

$.activityIndicator.hide();

答案 1 :(得分:0)

下面是我的控制器,查看钛合金中一页的文件

---- --- index.js

function login(e) {  
    var uname = $.username.value.split(' ').join('');
    var pwd = $.password.value.split(' ').join('');

    if(uname == ""){
        alert("Enter username.");
        return false;
    }
    if(pwd == ""){
        alert("Enter password.");
        return false;
    }




    //if(results.length == 0){
    if (Titanium.Network.networkType === Titanium.Network.NETWORK_NONE) {
           alert('There is no internet connection.');
           return false;
        } 

        var loginReq = Titanium.Network.createHTTPClient();
        var params = {
            func : "'"+Ti.Utils.base64encode('check_login')+"'",
            username : uname,
            password : pwd
        };
        loginReq.onload = function()
        {
            var json = this.responseText;
            var response = JSON.parse(json);
            if(response == 'account_inactive'){
                alert('Your account has been inactive. Please contact to your company');
                //$.index.close();
                var index = Alloy.createController('index').getView();
                index.open();
                return false;   

            }


           if(response == 'invalid'){
                alert('Invalid username or password');
                //$.index.close();
                var index = Alloy.createController('index').getView();
                index.open();
                return false;       
            }

            else
            {
                results = {
                    iuser_id: response.iuser_id,
                    signup_ids: response.signup_ids,
                    staff_id : response.staff_id,           
                    vusername: response.vusername,
                    vfirst_name: response.vfirst_name,
                    vlast_name: response.vlast_name,
                    vemail : response.vemail,
                    vpwd : response.vpwd
                    };  
                Ti.App.Properties.setObject("user_session",results);
                results = null;
                var flag = '';

                if (!Ti.App.Properties.hasProperty('installed')) 
                {
                    Ti.App.Properties.setBool('app:isLoggedIn', true);
                    Ti.App.Properties.hasProperty('installed');
                    Ti.App.Properties.setBool('installed', true);
                    var th_sign = Alloy.createController('login').getView();
                    th_sign.open();
                }
                else
                {

                    var th_sign = Alloy.createController('account').getView();
                    th_sign.open();
                }
                }       

            json = null;
            response = null;
        };
        if(os_name == 'android'){
        loginReq.open("GET", WEB_ROOT+"get_init.php");
        }
        else{
        loginReq.open("POST", WEB_ROOT+"get_init.php"); 
        }
        loginReq.send(params);

}
$.index.open();

---- INDEX.XML -------

<Alloy>
    <Window class="login_container" height="auto" horizontalWrap="true">
        <ScrollView id="scrollView_index" showVerticalScrollIndicator="true" height="100%" width="100%" scrollType="vertical">
            <View id="index_view">

                <ImageView class="logo" image="/images/login/logo.png" top='25' />

                <TextField id="username" class="usernameTxt" value="" border="0" top="230" />
                <TextField id="password" class="passwordTxt" value="" border="0" top="275" />
                <Button id="loginButton" class="login_bg" onClick="login">Login</Button>


            </View>     

        </ScrollView>       
    </Window>
</Alloy>

答案 2 :(得分:0)

通过使用活动指示器等待一段时间,我理解了你的说法和解释但这只能解决登录活动的问题。但无论我在哪里使用UI实用程序,如(按钮Onclick,Label onclick,Image Onclick,View Onclick)重定向到下一页至少需要4到5秒的时间。我也在切换两个页面之间使用了Loader但是仍需要时间(4到5秒)来实现点击事件并重定向到下一页

相关问题