cordova - Phonegap plugin (Version >=3.0) to retrieve registered email address of an Android device -


i need registered email of android device within cordova app. have cordova 3.3.0 app working; , find cordova plugin version 2.5 @ this place plugin not compatible version using. has provided updated plugin this?

how update plugin built 2.5, make compatible 3.3.0?

the plugin needs permission android.permission.get_accounts

update: did following accountlist.java file

package com.seltzlab.mobile;  import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject;  import android.accounts.account; import android.accounts.accountmanager; import android.content.context;  import org.apache.cordova.*;  import org.apache.cordova.cordovainterface; import org.apache.cordova.cordovaplugin; import org.apache.cordova.cordovawebview; import org.apache.cordova.pluginresult;  public class accountlist extends cordovaplugin {  private context ctx;  public pluginresult execute(string action, jsonarray args, string callbackid) { try { jsonobject obj = args.getjsonobject(0); accountmanager = accountmanager.get(this.ctx); account[] accounts; if (obj.has("type")) accounts = am.getaccountsbytype(obj.getstring("type")); else accounts = am.getaccounts(); jsonarray res = new jsonarray(); (int = 0; < accounts.length; i++) { account = accounts[i]; res.put(a.name); } return new pluginresult(pluginresult.status.ok, res); } catch (jsonexception e) { return new pluginresult(pluginresult.status.json_exception); } } } 

where, original -

package com.seltzlab.mobile; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import android.accounts.account; import android.accounts.accountmanager; import com.phonegap.api.plugin; import com.phonegap.api.pluginresult;  public class accountlist extends plugin {     @override   public pluginresult execute(string action, jsonarray args, string callbackid)  {       try {            jsonobject obj = args.getjsonobject(0);          accountmanager = accountmanager.get(this.ctx);            account[] accounts;          if (obj.has("type"))                 accounts = am.getaccountsbytype(obj.getstring("type"));          else                 accounts = am.getaccounts();             jsonarray res = new jsonarray();             (int = 0; < accounts.length; i++) {              account = accounts[i];                 res.put(a.name);             }            return new pluginresult(pluginresult.status.ok, res);        }  catch (jsonexception e) {            return new pluginresult(pluginresult.status.json_exception);         }    }} 

and script in html file follows -

  <script type="text/javascript" charset="utf-8" src="accountlist.js"></script>          <script type="text/javascript" charset="utf-8">         function getaccs(){         alert("get accounts function starts")          cordova.define("com.seltzlab.mobile.accountlist")          window.plugins.accountlist.get(                 {                     type: 'gmail' // if not specified accounts                 },                  function (result) {                     alert(res.length);             (i in res)                 alert(res[i]);                 },                 function (error) {                     alert(error);                 }             );          }         </script> 

i getting error saying accountlist undefined.

try contact cordova plugin retrieve registered email address android device

https://github.com/apache/cordova-plugin-contacts

example

function onsuccess(contacts) {     alert('found ' + navigator.contacts.length + ' navigator.contacts.'); };  function onerror(contacterror) {     alert('onerror!'); };  // find contacts 'bob' in name field var options      = new contactfindoptions(); options.filter   = "bob"; options.multiple = true; var fields       = ["displayname", "name","email"]; navigator.contacts.find(fields, onsuccess, onerror, options); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -