Contacts plugin

I watched your video on DropBox. As a windows users I can’t hook my phone to the simulator.

You may want to point out that nothing is going to happen when it is working. I was expecting at least a native pop when I tested on my phone. Nothing.

After watching your video I added this 

native.showAlert("Contacts", json.prettify(event) , { "OK" })

to 

local function Button1Event( event )

Nice pop showing my contact list.

Great Job Scott!

    local function Button1Event( event )         if ( "ended" == event.phase ) then             contacts.get(function(event)             native.showAlert("Contacts", json.prettify(event) , { "OK" })              --native.showAlert( "Status", tostring(event.status) , { "OK" })                 if event.status == "success" then                    -- native.showAlert( "Contacts", tostring(event.contacts) , { "OK" })                 end             end)         end     end

 

Sorry, some people have crazy amount of contacts. Putting them all in a native alert is not a smart idea. By the way you should be able to use adb on windows

https://docs.coronalabs.com/guide/basics/debugging/index.html

Hi Scott. Its seems another error occured testing with your example. Check this out.

2d272cd3_dbd9_4fa4_b5ff_a9e7864a5603.jpg

Could I get your full logs?

Scott, nope you can not run the simulator using your phone on Windows. Corona on windows is very limited I just hate using Mac.

I have well over 200 contact on my phone. The native pop is great for a single test. I not saying every single use or test. Without the pop a windows user has no idea if your contact plugin is working.

How about you supply an updated example showing the first 5 or so contacts. A simple for loop limit 5 or so should work. I think this would help with some of the question you’re getting.

I will try to add it but it is possible to do adb on windows.

https://forums.coronalabs.com/topic/35018-easiest-detailed-way-to-debug-corona-app-on-android-device/

Scott. Here’s the Log from Android Studio LogCat/Monitor.

https://filetea.me/t1s8Je5xRB4SOOC8ZxhNFKfMg

that link does not work, just paste it in the code box on forums with <>

Ops! Sorry

And now?

https://www.dropbox.com/s/8zw68g01mogdzj1/ErroLog.txt?dl=0

This TXT is the Full Log. But this one is just the moment when it crashes.

AllocSpace objects, 0(0B) LOS objects, 33% free, 29MB/44MB, paused 1.709ms total 135.693ms 12-05 16:47:47.691: I/Corona(8194): ERROR: Runtime error 12-05 16:47:47.691: I/Corona(8194): /Users/Palmeira/Downloads/contacts-demo-master/main.lua:18: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference 12-05 16:47:47.691: I/Corona(8194): Java Stack Trace: 12-05 16:47:47.691: I/Corona(8194): plugin.contacts.LuaLoader$get.invoke(LuaLoader.java:451) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.JavaToNativeShim.nativeTouchEvent(Native Method) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.JavaToNativeShim.touchEvent(JavaToNativeShim.java:416) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.input.RaiseTouchEventTask.executeUsing(RaiseTouchEventTask.java:39) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:170) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.events.EventManager.sendEvents(EventManager.java:91) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.Controller.updateRuntimeState(Controller.java:308) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623) 12-05 16:47:47.691: I/Corona(8194): com.ansca.corona.graphics.opengl.GLSurfaceVi 12-05 16:47:47.730: V/WindowManager(914): not Base app: Adding window Window{251f3fa2 u0 br.com.rodrigopalmeira.contatos/com.ansca.corona.CoronaActivity} at 5 of 11 12-05 16:47:48.076: I/MotoNetwCtrlr.MotoWifiHndlr(1138): handleMessage: Entered msg.what=1

Thanks I think I know the issue. Working on fix

this should be fixed, it may take an hour for update to process.

Yeyyy! It worked!

Thanks Scott. Your are the Best!  :smiley:

Captura_de_Tela_2016_12_06_a_s_08_44_04.

Hi Scott.

I’ve tested in many types of Android devices. It worked in all devices, but it seems to be running very slow in devices with android version lower than 5.0.

My tests in 6 different devices with Android version HIGHER then 5.0: About 5 Seconds to Process.

My tests in 2 different devices with Android version LOWER then 5.0: About 1 Minute and 30 Seconds to Process.

What do you think may be happening? Just weaker OS’s? 

Maybe an older and slower way of process contacts?

My plugin just uses the native android way of getting contacts. Performance depends on may things device, os, and number of contacts

Scott I’m failing at the “simple for loop” :slight_smile: Any assistance would be awesome

local contacts = e.contacts for i=1,#contacts do print(contacts[i].name) end

this assumes e is the event

Some questions of this plugin I want to ask, since these are the problems occurred in corona “native.showpopup”

  1. Will this plugin shows all types of the contact, including custom label?

  2. Will this plugin shows all records, including duplicated types? Since corona “native.showpopup” will not show the number with duplicated types

  1. I am guessing you mean like home and cell phone? please read docs on what data this plugin gets https://scotth.tech/plugin-contacts

I am not to familiar with custom labels.

  1. It should return all contact records. I notice the work show a lot. This plugin allows you to get all contacts info and use it in a table. You can make your own pop if you want or display them all. contacts.get returns a lua table for you to filter, add, remove, etc and handle how ever you want.

Since the document you mentioned is just said will display the following contact:

“mobile” (both)

“other” (both)

“work”(android)

“home” (android)

“main” (iOS)

“iPhone” (iOS)

“homeFax” (iOS)

“workFax” (iOS)

“otherFax” (iOS)

“pager” (iOS)

And iOS contact list has “custom label” (or you may call this “type”) that can be created by user, so I want to know if that label can get in list