gpt4 book ai didi

android - 试图查询联系人列表

转载 作者:行者123 更新时间:2023-11-29 00:42:14 25 4
gpt4 key购买 nike

根据我之前得到的答案,我在 BroadcastReceiver 中有这段代码:

Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(ASenderTel));
// Also tried;
//ContentResolver cr = getContentResolver();
//Context c = this;
Cursor c = getContentResolver().query(lookupUri, new String[] { PhoneLookup._ID }, null, null, null);
return (c.getCount() > 0);

...但是收到错误信息,“方法 getContentResolver() 未定义类型 KITSMSReceiver”

最佳答案

getContentResolver() 是 android.content.Context 类的一个方法。例如,您可以从您的 Activity 中访问它。为了实现它,将广播接收器放在 Activity 类中:

快速草稿:

public class MyActivity extends Activity {

// ...

private BroadcastReceiver myReceiver = new BroadcastReceiver() {
public void onReceive(Context c, Intent i) {
MyActivity.this.recvBroadcast(i); // forward to your activity
MyActivity.this.getContentResolver(); // <-----
}
}};

// ...

}

关于android - 试图查询联系人列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8640147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com