通过Android的通话记录获取通话中使用的SIM卡号码 [英] Get the SIM number used on a call through the call log of Android

查看:727
本文介绍了通过Android的通话记录获取通话中使用的SIM卡号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Android SDK对于双重SIM卡支持来说是一团糟,但是股票拨号器会在通话记录中显示此信息,而通话记录中使用了SIM卡(1或2)。我想它存储在呼叫日志默认数据库中,只是想知道是否有可能尽可能简单地检索它。我不需要知道SIM卡是否是当前使用的SIM卡。顺便说一句,如果您更换Sim卡,通话记录可能会变得一团糟...但是,这是另一个主题,对我来说并不重要(此刻;-)

I know Android SDK is big mess for dual SIM support, but stock dialer shows this information on call log which SIM card ( 1 or 2) was used in a call. I guess it´s stored on call log default database and just want to know if it is possible to retrieve it as simple as possible. I don´t need to know if the SIM is the current one in use. By the way, probably the call log became3s a big mess if you change the Sim cards... but it is another subject and does not matter for me (at the moment ;-)

我的问题:

1-是否可以得到?

1- Is it possible to get it ?

2-是对文件/数据库的简单查询吗?
我找到了一个名为2SIMCallLogger的应用程序,可在Google Play上找到。

2- Is it a simple query on the file/database? I found an app which does it called 2SIMCallLogger , available on Google Play.

有人猜到他们是怎么做到的吗?

Does anyone guess how they did it?

推荐答案

我的手机带有2张SIM卡,我从通话记录中获得了所有字段以及字段名称。
从结果中,名为 simid的字段显示哪个SIM卡处理了呼叫。

I have phone with 2 SIM cards, and I got all fields from calllog, and field names. From results, field named "simid" shows which SIM card handled call.

public void editToFile(){
    File file = new File(Environment.getExternalStorageDirectory(), "fileOut.txt");
    try{
        BufferedWriter writer = new BufferedWriter(new FileWriter(file,true));
        writer.write(mEdit.getText().toString());
        writer.newLine();
        writer.flush();
        writer.close();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}
public void getCallLogs(){
    final String[] projection = null;
    final String selection = null;
    final String[] selectionArgs = null;
    final String sortOrder = "DATE DESC";
    Cursor cursor = this.getContentResolver().query(Uri.parse("content://call_log/calls"),projection,selection,selectionArgs,sortOrder);
    int j=0;
    //mEdit is EditText
    mEdit.setText("");
    if (cursor != null) {
        int L=cursor.getColumnCount();
        for(int i=0;i<L;i++)
            mEdit.append(cursor.getColumnName(i) + "\t");
            mEdit.append("\n");
            while (cursor.moveToNext()) {
                j++;
            if(j>=5)
                break;
            for(int i=0;i<L;i++){
                String callField = cursor.getString(i);
                mEdit.append(callField + "\t");
            }
            mEdit.append("\n");
        }
    }
    editToFile();
}

这篇关于通过Android的通话记录获取通话中使用的SIM卡号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆