问题
I am developing a default Phone App for android like :
Having permissions listed in manifest and requested runtime too :
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Before requesting these permissions i have requested for the granting it as default via ACTION_CHANGE_DEFAULT_DIALER
intent first then permissions and then ACTION_MANAGE_OVERLAY_PERMISSION settings opened up for the user to switch it ON.
In My manifest.xml i have declared the service InCallService
implementation:
<service
android:name=".InCallServiceImplementation"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_INCALL_SERVICE">
<meta-data
android:name="android.telecom.IN_CALL_SERVICE_UI"
android:value="true" />
<meta-data
android:name="android.telecom.IN_CALL_SERVICE_RINGING"
android:value="true" />
<intent-filter>
<action android:name="android.telecom.InCallService" />
</intent-filter>
</service>
and
Activity which opens my apps dial pad when user initiates android.intent.action.DIAL
:
<activity
android:name=".DialerActivity"
android:label="@string/title_activity_dialer"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<!-- Handle links from other applications -->
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DIAL" />
<action android:name="android.intent.action.CALL" />
<!-- Populate the system chooser -->
<category android:name="android.intent.category.DEFAULT" />
<!-- Handle links in browsers -->
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tel" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
and my DialerActivity.java :
@Override
protected void onCreate(Bundle savedInstanceState)
{
if (getIntent() != null && getIntent().getData() != null)
{
Log.d("MainActivity URI :", getIntent().getData().getSchemeSpecificPart());
}
else
{
Log.d("MainActivity URI :", "NULL INTENT FOUND");
}
}
- My
InCallServiceImplementation
getting invoked when user initiates android.intent.action.CALL from calling button - But when user touches the phone number in recent calls within company provided phone app, which i think is a
android.intent.action.DIAL
and it should open my DialerActivity, but its not happening neither on emulator, nor on real device..
for your reference you can see i am printing
getSchemeSpecificPart
in my DialerActivity onCreate which never gets called.. Why it is not opening the dialer activity? I would like to thank you in advance.
来源:https://stackoverflow.com/questions/59567029/default-phone-app-intent-action-dial-not-opening-activity