阅读Android操作系统的 packages/apps/phone/AndroidManifest.xml,是如何暴露的
AndroidManifest.xml
Android操作系统在这里明确指定要这个权限:
我的应用去隐式意图激活,Android操作系统的 packages/apps/phone/
现在知道为什么,一定要在AndroidManifest.xml里面配置权限了吧
<!-- Android操作系统的 packages/apps/phone/AndroidManifest.xml 明确指定要打电话权限 android:permission="android.permission.CALL_PHONE" --> <uses-permission android:name="android.permission.CALL_PHONE" />
现在知道为什么,一定要这样才能激活 Android操作系统的 packages/apps/phone/ 通话功能了吧
Android操作系统 packages/assp/phone/ 暴露了很多 intent-filter,随意匹配一个intent-filter 就可以了,那就匹配下面的intent-filter
<!-- CALL action intent filters, for the various ways of initiationg an outgoing call. --> <intent-filter> <action android:name="android.intent.action.CALL" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="tel" /> </intent-filter>
Android操作系统 packages/assp/phone/AndroidManifest.xml/打电话相关 是怎么去intent-filter暴露的,我就怎么去激活
/** * 隐式意图方式激活 * 激活操作系统通话界面 * @param view */ public void startCall(View view) { /** * Android操作系统的 packages/apps/phone/AndroidManifest.xml 是这样暴露的 * <!-- CALL action intent filters, for the various ways of initiationg an outgoing call. --> * <intent-filter> * <action android:name="android.intent.action.CALL" /> * <category android:name="android.intent.category.DEFAULT" /> * <data android:scheme="tel" /> * </intent-filter> */ Intent intent = new Intent(); intent.setAction("android.intent.action.CALL"); // 在这里为什么不需要设置:category android:name="android.intent.category.DEFAULT",因为在startActivity会自动添加 intent.setData(Uri.parse("tel:1345678977")); // 必须要加 : startActivity(intent); }
效果图: