【问题标题】:how to make my android App faster using titanium App如何使用钛应用程序让我的安卓应用程序更快
【发布时间】:2016-04-27 06:34:39
【问题描述】:

我注意到当我使用钛合金在 Android 设备中部署应用程序时,它运行缓慢,并且似乎 android 应用程序在触摸和单击后需要时间重定向到下一页。它在我之后 3 或 4 秒内转到下一页点击任何 UI 元素(按钮、视图、标签、图像)

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

我不知道android到底应该有什么问题。我还在android中重置了我的工厂数据并再次测试了应用程序,但问题仍然出现

这是 android 触摸/点击问题吗?

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

【问题讨论】:

  • 你能发布一个有这个问题的控制器吗?

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


【解决方案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();

【讨论】:

    【解决方案2】:

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

    ----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>
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • 请不要添加答案,而是添加 cmets;无论如何,您的智能手机有多少 RAM 和哪个处理器?您可以尝试使用其他设备吗?
      猜你喜欢
      • 1970-01-01
      • 2012-02-02
      • 1970-01-01
      • 1970-01-01
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      相关资源
      最近更新 更多