Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

App or Platform crash on some android devices

$
0
0

Unfortunately, a few android (different android versions) users have one of the following problem with my app:

  • The app works without problems, when they change to Whatsapp and back it appears: System UI error
  • The task manager does not work properly
  • The top bar does not work properly

I did not get the error with my device or emulator. They can't send me any error log because the operating system crashes but not the app.

I use a standard titanium template with a webView ...

app.js

if (Ti.version < 1.8 ) {
    alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later'); 
} else {
    //require and open top level UI component
    var ApplicationWindow = require('ui/ApplicationWindow');
    new ApplicationWindow().open();
    ApplicationWindow = null;
}
 
// In my index.html i fire this event
Ti.App.addEventListener('app:getDeviceToken', function(e)
{
    var Cloud = require('ti.cloud');
    var CloudPush = require('ti.cloudpush');
    var user_device_token;
    var user_device_id;
    var username;
    var password = 'xxxxxx';
    var pushDeviceCount = 0;
 
    username = e.username;
    getDeviceToken();
 
    function getDeviceToken()
    {
        CloudPush.retrieveDeviceToken({
                success: function deviceTokenSuccess(e) {
                    user_device_token = e.deviceToken;
                    CloudPush.enabled = true;
                    login();
                },
                error: function deviceTokenError(e) {
                    alert('Failed to register for push! ' + e.error);
             }
        });
    }
 
 
    function login()
    {
        Cloud.Users.login({
                login: username,
                password: password
            },
            function (e) {
                if (e.success) {
                    var user = e.users[0];
                    user_device_id = user['id'];
                    subscribeToServerPush();
                }
                else {
                    registerUser();
                }
            }
        );
    }
 
    function registerUser(){
        Cloud.Users.create({
            username: username,
            password: password,
            password_confirmation: password
        }, function (e) {
            if (e.success) {
                login();
            }
            else {
                alert("Error register");
            }
        });
    }
 
    function subscribeToServerPush(){
        Cloud.PushNotifications.subscribe({
                channel: 'ljc',
                device_token: user_device_token
            }, function (e) {
                if (e.success) {
                    if(pushDeviceCount < 1)
            {
                pushDeviceCount++;
                        Ti.App.fireEvent('app:setDeviceID', { deviceid: user_device_id });
            }
                } else {
                    alert('Error ' + ((e.error && e.message) || JSON.stringify(e)));
                }
            }
        );
    }
 
    Cloud = null;
    CloudPush = null;
    user_device_token = null;
    user_device_id = null;
    username = null;
    password = null;
    xpushDeviceCount = null;    
});
ApplicationWindow.js
function ApplicationWindow() {
 
    var backgroundColor = '#ffffff';
 
    var self = Ti.UI.createWindow({
         backgroundColor : '#ffffff',
         navBarHidden:true,
        modal : true,
        exitOnClose : true  // Android only
    });   
 
    var webView = Titanium.UI.createWebView({
        backgroundColor : backgroundColor,
        enableZoomControls : false, // Android only
        url : '/HTML/index.html'
    });
    self.add(webView);    
 
    var activity = self.activity;
    activity.onCreateOptionsMenu = function(e)
    {
        var menu = e.menu;
        var news = menu.add(
        { 
            title: "News",
            showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM
        });
        var gaestebuch = menu.add(
        { 
            title: "Gästebuch",
            showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM
        });
        var chat = menu.add(
        { 
            title: "Chat",
            showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM
        });
        news.addEventListener("click", function(e)
        {
            webView.evalJS('document.location.href = "news.html";');
        });
        gaestebuch.addEventListener("click", function(e)
        {
            webView.evalJS('document.location.href = "gaestebuch.html";');
        });
        chat.addEventListener("click", function(e)
        {
            webView.evalJS('document.location.href = "chat.html";');
        });
    };
    activity = null;
 
    return self;
}
 
module.exports = ApplicationWindow;
Can anyone help me with it?

Titanium SDK: 3.1.2.GA


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>