Quantcast
Viewing all articles
Browse latest Browse all 8068

Android Address book application crashed

Hi i am Add button click to open device ContactBook after i get the contact by using select person method to get contact and store in propertyfile after getstring to get and show in tableview in the mean time i have facing application crash problem.Please help me urgently i need any solution.Sorry for the English.

here below my code:

function Androidcontactspage(_args) {
 
    var contacts = [];
    var manoId;
 
    if(Ti.App.Properties.hasProperty('Contacts')){
        contacts = Ti.App.Properties.getList('Contacts');
    }
 
    Ti.include('/ui/common/support/CustomUI.js');
 
    var self = createWindow('Contacts');
        self.backgroundColor = '#ffffff';
 
        self.orientationModes = [
        Titanium.UI.PORTRAIT,
        ];
 
    var NavigationBar = require('ui/common/support/NavigationBar');
 
    var customNavigation = NavigationBar.customNavigationBar({
        title : 'Contacts',
        navBackTitle : 'Back',
        isShowBackButton : true,
        isShowAddButton : true,
        isShowLogoutButton : false,
        isShowRightButton : false,
        isShowLeftButton : false,
        });
 
    customNavigation.addEventListener('navigationBackButtonPressed', function(e) {
    self.close({
            animated : true
 
        });
    });
 
    customNavigation.addEventListener('AddButtonPressed', function(e) {
 
        Ti.Contacts.showContacts(values);
 
    });
    self.add(customNavigation);
 
    var values = {cancel:function() {}};
 
 
    var addressBookDisallowed = function(){
        alert('Edit your iPhone privacy settings to allow Contacts');
    };
 
    //@TODO: Need to implement this to get permission
    var performAddressBookFunction = function(){
        if (Ti.Platform.osname === 'android') {
 
 
         // android doesn't have the selectedProperty support, so go ahead and force selectedPerson
            values.selectedPerson = function(e) {
                    var person = e.person;
                    var found = false;
                    for(var i = 0; i < contacts.length; i++) {
                                    if (contacts[i].id == person.id) {
                                        found = true;
 
                                        break;
                                    }
                                }
                                if(found == false){
 
                                    contacts.push({title:person.fullName, hasChild:true, id:person.id, phone:person.phone.mobile, color: '#000'});
                                    Ti.App.Properties.setList('Contacts', contacts);
                                    table.fireEvent('click', {rowData: {title:person.fullName, hasChild:true, recordId:person.id, phone:person.phone.mobile, color: '#000'} });
 
                                }
 
                                table.data = contacts;
            };
        }
 
 
 };
 
 
    if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED){
        performAddressBookFunction();
    }else{
        Ti.API.info('Contacts access unknown');
        Ti.Contacts.requestAuthorization(function(e){
            if (e.success) {
                performAddressBookFunction();
            } else {
                addressBookDisallowed();
            }
        });
    } 
 
 
    var table = Ti.UI.createTableView({
        data:contacts,
 
        });
        self.add(table);
 
 
   table.addEventListener('click', function(e)
    {
        var ContactsDetail = require('ui/common/AndroidEMGDetail');
             win = new ContactsDetail();
 
         _args.containingTab.open(win,{animated:true});
 
        var evtData = {
 
            testValue:'test',
            id:e.rowData.id,
            title:e.rowData.title,
            phone:e.rowData.phone
 
 
 
            };
 
        Ti.App.fireEvent('app:myEvent',evtData);
 
 
     });
 
  Ti.App.addEventListener('refreshContacts', function(e)
    {
        contacts = Ti.App.Properties.getList('Contacts');
        table.data = contacts;
    });
 
 
    return self;
};
 
module.exports = Androidcontactspage;

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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