CallLog에 수신.발신. 부재중통화를 이미지로 표현해 보다가 질문 드립니다. > QnA

본문 바로가기

사이트 내 전체검색

QnA

안드로이드 CallLog에 수신.발신. 부재중통화를 이미지로 표현해 보다가 질문 드립니다.

페이지 정보

청솔 20-08-28 00:38 조회 322회 댓글 5건

본문

청솔님의 댓글

profile_image 청솔 작성일

2020-08-28 00:41:56.182 759-759/? E/cnss-daemon: Stale or unreachable neighbors, ndm state: 4
2020-08-28 00:42:03.462 759-759/? E/cnss-daemon: Stale or unreachable neighbors, ndm state: 16
2020-08-28 00:42:06.562 1607-3499/? E/LocSvc_libulp: I/int ulp_msg_process_system_update(const UlpSystemEvent): systemEvent:5
2020-08-28 00:42:06.563 1607-3499/? E/LocSvc_libulp: I/===> int ulp_brain_turn_onoff_dr_provider() line 848
2020-08-28 00:42:06.563 1607-3499/? E/LocSvc_libulp: I/===> int ulp_dr_stop_engine() line 235
2020-08-28 00:42:06.563 1607-3499/? E/LocSvc_libulp: I/int ulp_msg_process_start_req(), at ulp state = 1
2020-08-28 00:42:06.563 1607-1996/? E/LocSvc_api_v02: I/---> locClientSendReq line 2069 QMI_LOC_GET_BEST_AVAILABLE_POSITION_REQ_V02
2020-08-28 00:42:06.570 1607-2005/? E/LocSvc_ApiV02: I/<--- void globalRespCb(locClientHandleType, uint32_t, const locClientRespIndUnionType, uint32_t, void *) line 140 QMI_LOC_GET_BEST_AVAILABLE_POSITION_REQ_V02
2020-08-28 00:42:06.571 1607-3499/? E/LocSvc_libulp: I/int ulp_brain_process_zpp_position_report(const enum loc_sess_status, LocPosTechMask, UlpLocation *), report ZPP position to providers,report_position = 1
2020-08-28 00:42:06.571 1607-3499/? E/LocSvc_libulp: I/===> int ulp_brain_turn_onoff_dr_provider() line 848
2020-08-28 00:42:06.571 1607-3499/? E/LocSvc_libulp: I/===> int ulp_dr_stop_engine() line 235

청솔님의 댓글

profile_image 청솔 작성일

이렇게도 해 보았습니다만...

        fun setPhone(call: Call) {
            mCall = call
            itemView.textName.text = call.name ?: ""
            itemView.textPhone.text = call.phone ?: ""
            itemView.callType.text = call.type?.toLong().toString() ?: ""

when(itemView.callType) {
                CallLog.Calls.INCOMING_TYPE -> itemView.setImageResource(R.drawable.ic_call1_received)
                CallLog.Calls.OUTGOING_TYPE -> itemView.setImageResource(R.drawable.ic_call2_send)
                CallLog.Calls.MISSED_TYPE -> itemView.setImageResource(R.drawable.ic_call3_missed)
                else ->itemView.setImageResource(R.drawable.cancelled)
            }

청솔님의 댓글

profile_image 청솔 작성일

선생님이 강의하시고 GitHub에 올려주신 Call Log는
1. 저사양에서는 설치가 되질 않습니다.(Call Log 추가 이후)
2. 저희 가족 최신폰으로는 설치는 잘 되지만, 전부 이미지는 나오질 않습니다.

죽어라 궁리해보다가..      CallLog.Calls.CACHED_PHOTO_ID,  ....에서
_id 가 문제가 있지 않을까.. 다른 걸 대입시켜야 할 것 같기도 하구요.

Scott님의 댓글

profile_image Scott 작성일

전체 코드를 올리셔야 될것 같습니다. 이걸로는 원인을 찾기 어렵습니다

청솔님의 댓글

profile_image 청솔 작성일

package com.sun.phone

import android.annotation.SuppressLint
import android.os.Bundle
import android.provider.CallLog
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.fragment_calllog.view.*
import kotlinx.android.synthetic.main.item_calllog.*


class CallLogFragment : Fragment() {

    lateinit var mAdapter: CallLogAdapter
    var callList = mutableListOf<Call>()
    var searchText = ""
    var sortText = "asc"

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = inflater.inflate(R.layout.fragment_calllog, container, false)
        setContentView(view)  //화면을 그려주는 함수

        return view
    }

    fun setContentView(view:View) {  //화면을 그려주는 함수
        callList.addAll(getPhoneNumbers(sortText, searchText))
        mAdapter = CallLogAdapter(callList)
        view.recycler.adapter = mAdapter
        view.recycler.layoutManager = LinearLayoutManager(context)
    }


    @SuppressLint("MissingPermission")
    fun getPhoneNumbers(sort:String, name:String) : List<Call>{
        val list = mutableListOf<Call>()

        val callLogUri = CallLog.Calls.CONTENT_URI
        var proj = arrayOf(
            CallLog.Calls.PHONE_ACCOUNT_ID,
            CallLog.Calls.CACHED_NAME,
            CallLog.Calls.NUMBER,
            CallLog.Calls.CACHED_PHOTO_ID,
            CallLog.Calls.DATE,
            CallLog.Calls.TYPE) 



        context?.run {
            val cursor = contentResolver
                .query(callLogUri, proj, null, null, null)

            while(cursor?.moveToNext() == true) {
                val id = cursor?.getString(0)
                val name = cursor?.getString(1)
                var number = cursor?.getString(2)
                var photoUri = cursor?.getString(3)
                var date= cursor?.getLong(4)
                var type = cursor?.getLong(5)

// callType는 calllog.xml  type 가 들어가는 자리
                when (callType) {
                    CallLog.Calls.INCOMING_TYPE -> type = imageView.setImageResource(R.drawable.ic_call1_received)
                    CallLog.Calls.OUTGOING_TYPE -> type = imageView.setImageResource(R.drawable.ic_call2_send)
                    CallLog.Calls.MISSED_TYPE -> type = imageView.setImageResource(R.drawable.ic_call3_missed)            }
                    else -> type = imageView.setImageResource(R.drawable.cancelled)

                val call = Call(id, name, number, photoUri, date, type)
                list.add(call)
            }
        }

        return list
    }
}

Copyright © flow9.net All rights reserved.