在我的应用程序中,我想检测来电,我想用我的自定义布局隐藏默认的来电布局,到目前为止,我已经设法获得来电的状态,但我无法隐藏默认的来电屏幕.. .below 是我的代码和我的 android 清单文件...任何帮助将不胜感激..
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.i("DEBUG", "on recive called");
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
String number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state))
{
abortBroadcast();
Log.d("MPR", "Its Ringing [" + number + "]");
//start activity
Intent i = new Intent();
i.setClassName("com.ezest.callerid", "com.ezest.callerid.CustomCallActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
if (TelephonyManager.EXTRA_STATE_IDLE.equals(state))
{
Log.d("MPR", "Its Idle");
}
if (TelephonyManager.EXTRA_STATE_OFFHOOK.equals(state))
{
Log.d("MPR", "Its OffHook");
}
}
显现
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<receiver android:name="MYPhoneStateListener">
<intent-filter android:priority="999999">
<action android:name="android.intent.action.PHONE_STATE"></action>
</intent-filter>
</receiver>
<activity
android:label="@string/app_name"
android:name=".CallerIDActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="CustomCallActivity">
</activity>
</application>