[英]Authority com.android.contacts not found exception when doing applyBatch
[英]ShowCallLog Intent not working when handled by "com.android.contacts"
我正在嘗試使用意圖和 startActivity(ForResult) 從我的應用程序中打開通話記錄活動。
它確實工作正常,除了在某些設備上。
經過調查,我注意到當意圖解決此 class 時:
ComponentName("com.android.contacts", "com.android.contacts.NonPhoneActivity")
然后startActivity
(或startActivityForResult
) “無效”/不顯示 CallLogs 。 根據名稱“NonPhoneActivity”,我猜這是有道理的..
(有關此NonPhoneActivity
活動的信息:
https://android.googlesource.com/platform/packages/apps/Contacts/+/master/AndroidManifest.xml )
這是代碼(僅供參考,使用startActivityForResult
;我觀察到與startActivity
相同的行為:
additionalButtonsBinding.phoneSelectContactFragmentButtonsMissedCallButton.setOnClickListener(v -> {
Intent showCallLog = new Intent();
showCallLog.setAction(Intent.ACTION_VIEW); // "android.intent.action.VIEW"
showCallLog.setType(CallLog.Calls.CONTENT_TYPE); // "vnd.android.cursor.dir/calls"
showCallLogLauncher.launch(showCallLog);
});
showCallLogLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
// result is always {resultCode=RESULT_CANCELED, data=null}
// may the CallLogs be shown OR not
// so startActivityForResult is useless: just here fore investigation purpose and completeness of my question
Log.d(TAG, result.toString());
}
});
問題:
ComponentName("com.android.contacts", "com.android.contacts.NonPhoneActivity")
...即使在電話上!"com.android.dialer",com.android.dialer.main.impl.MainActivity"
,它能夠顯示 CallsLogs"com.android.contacts", "com.android.contacts.NonPhoneActivity"
)有時/通常是唯一能夠處理Intent { act=android.intent.action.VIEW typ=vnd.android.cursor.dir/calls }
的組件(*)
Intent { act=android.intent.action.VIEW typ=vnd.android.cursor.dir/calls }
,我應該使用另一個意圖(另一個動作)來顯示呼叫日志嗎? *
:根據結果PackageManager.queryIntentActivities(showCallLog, PackageManager.MATCH_ALL)
,這是一個只有一項的列表,即"com.android.contacts", "com.android.contacts.NonPhoneActivity"
釘住它(幾乎):
安裝 Google Dialer (Google Phone) 應用后,可以使用以下意圖操作: com.android.phone.action.RECENT_CALLS
:
Intent googleDialerShowRecent = new Intent("com.android.phone.action.RECENT_CALLS");
if (BaseApplication.getInstance().getPackageManager().queryIntentActivities(googleDialerShowRecent, PackageManager.MATCH_ALL).size() > 0) {
showCallLogLauncher.launch(googleDialerShowRecent);
}
我只是不知道如何強制 Google Phone 應用在啟動時顯示“歷史記錄”/“最近通話”標簽。
Google Phone 的清單摘錄:
<activity
android:name="com.android.dialer.main.impl.MainActivity"
...>
<intent-filter android:label="@ref/0x7f150123">
<action android:name="com.android.phone.action.RECENT_CALLS" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.TAB" /> TAB HERE - Could I send some EXTRA in INTENT to force Google Dialer to display the 'recent call' TAB?
</intent-filter>
問題:
在清單中我們可以看到: <category android:name="android.intent.category.TAB" />
我如何使用它來強制 Google Phone 應用顯示“最近通話”標簽? 在意圖中添加一些額外的? 哪一個?
(我知道,我們沒有 Google Phone 應用程序的源代碼,但是,希望他們使用一些(意圖中 EXTRA 的標准系統/命名約定)..
任何人?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.