我这样做是为了实现我的实际目标是How调用函数后的Android拨号器使用PhoneGap的插件已完成的呼叫,对我目前的问题或实际客观任何帮助是pciated深深AP $ P $
这是一个PhoneGap的应用程序,用户退出拨号器,并返回到我的PhoneGap的应用程序,我想onActivityResult被称为后。我不能够得到onActivityResult火了一段unknownreason。
myDialer.java
包org.apache.cordova;
进口org.apache.cordova.api.CallbackContext;
进口org.apache.cordova.api.CordovaPlugin;
进口org.json.JSONArray;
进口org.json.JSONException;
进口android.net.Uri;
进口android.telephony.PhoneStateListener;
进口android.util.Log;
进口android.content.Intent;
公共类电话拨号扩展CordovaPlugin {
私人CallbackContext callbackContext;
私有静态最终诠释ACTIVITY_ENDED = 2;
公共布尔执行(串动,JSONArray的args,CallbackContext callbackContext)抛出JSONException {
this.callbackContext = callbackContext;
如果(调用.equals(动作)){
尝试{
乌里数= Uri.parse(电话:+ args.getString(0));
意图callIntent =新的意图(Intent.ACTION_CALL,数量);
Log.e(NULL,在这里1);
。this.cordova.getActivity()startActivityForResult(callIntent,ACTIVITY_ENDED);
Log.e(NULL,在这里2);
}赶上(例外五){
}
返回true;
}
返回false;
}
公共无效onActivityResult(INT申请code,INT结果code,
意图数据){
Log.e(NULL,这里3+请求code +);
如果(要求code == ACTIVITY_ENDED)
{
Log.e(NULL,在这里4+请求code +);
callbackContext.success(); // javascript的成功回调,一旦用户退出拨号程序
}
}
}
令人不解的我有另外一个插件调用onActivityResult在我的项目,它似乎运作良好,我想比较,唯一的区别似乎是在我打电话this.cordova.getActivity()。startActivityForResult(callIntent,ACTIVITY_ENDED方式); 和 cordova.startActivityForResult(这一点,意图,CHOOSE_CONTACT);
这工作满code如下:
包org.apache.cordova;
进口android.app.Activity;
进口android.content.Context;
进口android.content.Intent;
进口android.database.Cursor;
进口android.net.Uri;
进口android.provider.ContactsContract;
进口android.provider.ContactsContract.Intents;
进口android.provider.ContactsContract.PhoneLookup;
进口android.util.Log;
进口org.apache.cordova.api.CallbackContext;
//进口org.apache.cordova.api.CordovaPlugin;
进口org.apache.cordova.api.PluginResult;
进口org.json.JSONArray;
进口org.json.JSONObject;
公共类ContactPickerPlugin扩展org.apache.cordova.api.CordovaPlugin {
私人上下文的背景下;
私人CallbackContext callbackContext;
私有静态最终诠释CHOOSE_CONTACT = 1;
私有静态最终诠释INSERT_CONTACT = 2;
@覆盖
公共布尔执行(串动,JSONArray数据,
CallbackContext callbackContext){
this.callbackContext = callbackContext;
this.context = cordova.getActivity()getApplicationContext()。
如果(action.equals(chooseContact)){
意向意图=新的意图(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
cordova.startActivityForResult(这一点,意图,CHOOSE_CONTACT);
PluginResult R =新PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(真正的);
callbackContext.sendPluginResult(r)的;
返回true;
}否则,如果(action.equals(的addContact)){
意向意图=新的意图(ContactsContract.Intents.Insert.ACTION,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
尝试 {
JSONObject的接触= data.getJSONObject(0);
如果(联系!= NULL){
intent.putExtra(Intents.Insert.NAME,contact.getString(显示名));
intent.putExtra(Intents.Insert.EMAIL,contact.getString(电子邮件));
intent.putExtra(Intents.Insert.PHONE_TYPE,ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
intent.putExtra(Intents.Insert.PHONE,contact.getString(移动电话号码));
}
}赶上(例外前){
}
intent.putExtra(finishActivityOnSaveCompleted,真正的);
cordova.startActivityForResult(这一点,意图,INSERT_CONTACT);
PluginResult R =新PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(真正的);
callbackContext.sendPluginResult(r)的;
返回true;
}
返回false;
}
@覆盖
公共无效onActivityResult(INT申请code,INT结果code,意图数据){
如果(结果code!= Activity.RESULT_OK)
返回;
乌里联系数据= data.getData();
光标C = context.getContentResolver()查询(联络人资料,NULL,NULL,
NULL,NULL);
字符串ID =;
如果(要求code == INSERT_CONTACT){
c.moveToLast();
ID = c.getInt(c.getColumnIndexOrThrow(PhoneLookup._ID))+;
}否则,如果(要求code == CHOOSE_CONTACT){
c.moveToFirst();
ID = c.getInt(C
.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.CONTACT_ID))
+;
}
尝试 {
字符串名称= C
.getString(C
.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
字符串email =;
光标emailCur = context.getContentResolver()查询(
ContactsContract.CommonDataKinds.Email.CONTENT_URI,空,
ContactsContract.CommonDataKinds.Email.CONTACT_ID +=?,
新的String [] {ID},NULL);
而(emailCur.moveToNext())
电子邮件= emailCur
.getString(emailCur
.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
emailCur.close();
光标phonesCur = context.getContentResolver()查询(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,空,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +=?,
新的String [] {ID},NULL);
JSONObject的手机=新的JSONObject();
JSONArray homeNumper =新JSONArray();
JSONArray移动电话号码=新JSONArray();
JSONArray workNumper =新JSONArray();
JSONArray faxWorkNumper =新JSONArray();
JSONArray faxHomeNumper =新JSONArray();
JSONArray pagerNumper =新JSONArray();
JSONArray otherNumper =新JSONArray();
JSONArray callbackNumper =新JSONArray();
JSONArray carNumper =新JSONArray();
JSONArray companyMainNumper =新JSONArray();
JSONArray isdnNumper =新JSONArray();
JSONArray mainNumper =新JSONArray();
JSONArray otherFaxNumper =新JSONArray();
JSONArray radioNumper =新JSONArray();
JSONArray telexNumper =新JSONArray();
JSONArray ttyTddNumper =新JSONArray();
JSONArray workMobileNumper =新JSONArray();
JSONArray workPagerNumper =新JSONArray();
JSONArray assistantNumper =新JSONArray();
JSONArray mmsNumper =新JSONArray();
而(phonesCur.moveToNext()){
整型= phonesCur
.getInt(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
开关(类型){
案例ContactsContract.CommonDataKinds.Phone.TYPE_HOME:
homeNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(homeNumper,homeNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE:
手机号
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(移动电话号码,移动电话号码);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_WORK:
workNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(workNumper,workNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK:
faxWorkNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(faxWorkNumper,faxWorkNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME:
faxWorkNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(faxHomeNumper,faxHomeNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_PAGER:
pagerNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(pagerNumper,pagerNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_OTHER:
otherNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(otherNumper,otherNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_CALLBACK:
callbackNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(callbackNumper,callbackNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_CAR:
carNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(carNumper,carNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN:
companyMainNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(companyMainNumper,companyMainNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_ISDN:
isdnNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(isdnNumper,isdnNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_MAIN:
mainNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(mainNumper,mainNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_OTHER_FAX:
otherFaxNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(otherFaxNumper,otherFaxNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_RADIO:
radioNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(radioNumper,radioNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_TELEX:
telexNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(telexNumper,telexNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_TTY_TDD:
ttyTddNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(ttyTddNumper,ttyTddNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE:
workMobileNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(workMobileNumper,workMobileNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER:
workPagerNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(workPagerNumper,workPagerNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT:
assistantNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(assistantNumper,assistantNumper);
打破;
案例ContactsContract.CommonDataKinds.Phone.TYPE_MMS:
mmsNumper
。把(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put(mmsNumper,mmsNumper);
打破;
}
}
phonesCur.close();
JSONObject的接触=新的JSONObject();
contact.put(身份证,身份证);
contact.put(邮件,邮件);
contact.put(显示名,名);
contact.put(手机,手机);
callbackContext.success(接触);
c.close();
}赶上(例外五){
Log.v(WAPP,分析接触失败:+ e.getMessage());
callbackContext.error(分析接触失败:+ e.getMessage());
}
}
}
解决方案
这是不可能有一个回调ACTION_CALL,不得不尝试其他的方式来满足我的首要目标。
来源 Android startActivityForResult,的setResult,onActivityResult不叫
这里注意:输出=无。 的http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL
I am doing this to achieve my actual objective which is How to call a function after Android dialer has completed call using Phonegap Plugin , any help on my current question or actual objective is deeply appreciated
This is a phonegap app, after the user exits the dialer and returns to my phonegap app I want the onActivityResult to be called. I am not able to get the onActivityResult to fire for some unknownreason.
myDialer.java
package org.apache.cordova;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.net.Uri;
import android.telephony.PhoneStateListener;
import android.util.Log;
import android.content.Intent;
public class PhoneDialer extends CordovaPlugin {
private CallbackContext callbackContext;
private static final int ACTIVITY_ENDED = 2;
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException{
this.callbackContext = callbackContext;
if ("call".equals(action)) {
try{
Uri number = Uri.parse("tel:" + args.getString(0));
Intent callIntent = new Intent(Intent.ACTION_CALL, number);
Log.e(null, "here 1");
this.cordova.getActivity().startActivityForResult(callIntent, ACTIVITY_ENDED);
Log.e(null, "here 2");
} catch (Exception e) {
}
return true;
}
return false;
}
public void onActivityResult(int requestCode, int resultCode,
Intent data) {
Log.e(null, "here 3"+requestCode+"");
if(requestCode == ACTIVITY_ENDED)
{
Log.e(null, "here 4"+requestCode+"");
callbackContext.success(); // javascript success callback once the user exits the dialer app
}
}
}
Mysteriously I have another plugin invoking the onActivityResult in my project, and it seems to be working well, I tried comparing the only difference seems to be in the way I call this.cordova.getActivity().startActivityForResult(callIntent, ACTIVITY_ENDED); and cordova.startActivityForResult(this, intent, CHOOSE_CONTACT);
That working full code is as follows
package org.apache.cordova;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.PhoneLookup;
import android.util.Log;
import org.apache.cordova.api.CallbackContext;
//import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONObject;
public class ContactPickerPlugin extends org.apache.cordova.api.CordovaPlugin {
private Context context;
private CallbackContext callbackContext;
private static final int CHOOSE_CONTACT = 1;
private static final int INSERT_CONTACT = 2;
@Override
public boolean execute(String action, JSONArray data,
CallbackContext callbackContext) {
this.callbackContext = callbackContext;
this.context = cordova.getActivity().getApplicationContext();
if (action.equals("chooseContact")) {
Intent intent = new Intent(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
cordova.startActivityForResult(this, intent, CHOOSE_CONTACT);
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
} else if (action.equals("addContact")) {
Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
try {
JSONObject contact = data.getJSONObject(0);
if (contact != null) {
intent.putExtra(Intents.Insert.NAME, contact.getString("displayName"));
intent.putExtra(Intents.Insert.EMAIL, contact.getString("email"));
intent.putExtra(Intents.Insert.PHONE_TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
intent.putExtra(Intents.Insert.PHONE, contact.getString("mobileNumber"));
}
} catch (Exception ex) {
}
intent.putExtra("finishActivityOnSaveCompleted", true);
cordova.startActivityForResult(this, intent, INSERT_CONTACT);
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
return false;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_OK)
return;
Uri contactData = data.getData();
Cursor c = context.getContentResolver().query(contactData, null, null,
null, null);
String id = "";
if (requestCode == INSERT_CONTACT) {
c.moveToLast();
id = c.getInt(c.getColumnIndexOrThrow(PhoneLookup._ID)) + "";
} else if (requestCode == CHOOSE_CONTACT) {
c.moveToFirst();
id = c.getInt(c
.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.CONTACT_ID))
+ "";
}
try {
String name = c
.getString(c
.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
String email = "";
Cursor emailCur = context.getContentResolver().query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?",
new String[] { id }, null);
while (emailCur.moveToNext())
email = emailCur
.getString(emailCur
.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
emailCur.close();
Cursor phonesCur = context.getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
new String[] { id }, null);
JSONObject phones = new JSONObject();
JSONArray homeNumper = new JSONArray();
JSONArray mobileNumber = new JSONArray();
JSONArray workNumper = new JSONArray();
JSONArray faxWorkNumper = new JSONArray();
JSONArray faxHomeNumper = new JSONArray();
JSONArray pagerNumper = new JSONArray();
JSONArray otherNumper = new JSONArray();
JSONArray callbackNumper = new JSONArray();
JSONArray carNumper = new JSONArray();
JSONArray companyMainNumper = new JSONArray();
JSONArray isdnNumper = new JSONArray();
JSONArray mainNumper = new JSONArray();
JSONArray otherFaxNumper = new JSONArray();
JSONArray radioNumper = new JSONArray();
JSONArray telexNumper = new JSONArray();
JSONArray ttyTddNumper = new JSONArray();
JSONArray workMobileNumper = new JSONArray();
JSONArray workPagerNumper = new JSONArray();
JSONArray assistantNumper = new JSONArray();
JSONArray mmsNumper = new JSONArray();
while (phonesCur.moveToNext()) {
int type = phonesCur
.getInt(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
switch (type) {
case ContactsContract.CommonDataKinds.Phone.TYPE_HOME:
homeNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("homeNumper", homeNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE:
mobileNumber
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("mobileNumber", mobileNumber);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_WORK:
workNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("workNumper", workNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK:
faxWorkNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("faxWorkNumper", faxWorkNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME:
faxWorkNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("faxHomeNumper", faxHomeNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_PAGER:
pagerNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("pagerNumper", pagerNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER:
otherNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("otherNumper", otherNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_CALLBACK:
callbackNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("callbackNumper", callbackNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_CAR:
carNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("carNumper", carNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN:
companyMainNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("companyMainNumper", companyMainNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_ISDN:
isdnNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("isdnNumper", isdnNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_MAIN:
mainNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("mainNumper", mainNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER_FAX:
otherFaxNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("otherFaxNumper", otherFaxNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_RADIO:
radioNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("radioNumper", radioNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_TELEX:
telexNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("telexNumper", telexNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_TTY_TDD:
ttyTddNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("ttyTddNumper", ttyTddNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE:
workMobileNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("workMobileNumper", workMobileNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER:
workPagerNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("workPagerNumper", workPagerNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT:
assistantNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("assistantNumper", assistantNumper);
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_MMS:
mmsNumper
.put(phonesCur.getString(phonesCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
phones.put("mmsNumper", mmsNumper);
break;
}
}
phonesCur.close();
JSONObject contact = new JSONObject();
contact.put("id", id);
contact.put("email", email);
contact.put("displayName", name);
contact.put("phones", phones);
callbackContext.success(contact);
c.close();
} catch (Exception e) {
Log.v("wapp", "Parsing contact failed: " + e.getMessage());
callbackContext.error("Parsing contact failed: " + e.getMessage());
}
}
}
解决方案
It is not possible to have a callback for ACTION_CALL, have to try other ways to meet my primary objective
Sources Android startActivityForResult, setResult, onActivityResult not called
"Note here: output = None." http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL
相关推荐
最新文章