如何打開自定義用戶界面上的回答和拒絕按鈕,我想顯示自定義用戶界面,而不是默認撥號。 我使用下面的代碼,但撥號器是開放的,我的行爲沒有被打開:中斷來電android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.callintruptdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".IncomingCall"></activity>
<receiver android:name=".CallReceiver">
<intent-filter >
<action android:name="android.intent.action.PHONE_STATE"></action>
</intent-filter>
</receiver>
</application>
我有一個廣播接收器監聽來電和接收器:
@Override
public void onReceive(Context context, Intent intent) {
Log.d("CallReceiver","IncomingBroadcastReceiver: onReceive: ");
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
Log.d("CallReceiver","IncomingBroadcastReceiver: onReceive: " + state);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING))
{
Intent i = new Intent(context, IncomingCall.class);
i.putExtras(intent);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
和IncomingCall類的代碼是:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
setContentView(R.layout.activity_main);
String number = getIntent().getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
TextView text = (TextView)findViewById(R.id.text);
text.setText("Incoming call from " + number);
}
但我的自定義UI是沒有顯示。
我也想要我的用戶界面上的按鈕,以及如何通過點擊該按鈕來接收來電。 在此先感謝。
編輯: - 更新我的代碼後,我可以打開我的自定義用戶界面,現在我想通過單擊按鈕來接收呼叫。如何做到這一點任何幫助..
也許你的設備已經選擇默認的撥號器總是接聽來電。做一個網絡搜索如何清除你的默認應用程序。 – npace
我在模擬器上測試它,當我運行應用程序它顯示撥號程序,但是當我調試應用程序,它顯示我的自定義用戶界面。所以我失蹤。 – Ravi
檢查此[鏈接] [1],[LINK1] [2],和[鏈接] [3] [1]:http://stackoverflow.com/questions/9256218/show-my-活動,而不是標準屏幕的來電 [2]:http://stackoverflow.com/questions/8699257/popup-over-incoming-call-screen [3]:http: //stackoverflow.com/questions/2486547/android-incoming-call-screen –