2

我正在尝试在本地拨出呼叫者屏幕顶部启动我的自定义屏幕,该屏幕可能包含呼叫者的全屏图像和一些用于拒绝呼叫等操作的按钮。使用它我可以拨打电话,但会将我重定向到本机呼叫者屏幕......

如何replace\override通过我的自定义屏幕屏幕来默认呼叫屏幕?

startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phonenumber)));
public class GetOutgoingNUmber extends BroadcastReceiver {


final static String INTENT_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.v("DileBroadCastReceiver","In onReceive()");

    if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {

         new Handler().postDelayed(new Runnable() {
             @Override
             public void run() {
                 Intent i = new Intent(context, OutGoingScreen.class);
                i.putExtras(intent);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                context.startActivity(i);
             }
         }, 1000);
}

这里 OutGoingScreen 用于显示传出屏幕

  public class OutGoingScreen extends Activity {
 @Override
    protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.outgoingscreen );

    }
}

现在的问题是它显示我的屏幕几毫秒并再次显示本机屏幕......?

4

3 回答 3

2

为拨出电话编写接收器

public class OutgoingCallReceiver extends BroadcastReceiver {
@Override
    public void onReceive(final Context context, final Intent intent) {
      //Write intent for yout page
  }
}

将这些添加到清单

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<receiver android:name=.OutgoingCallReceiver" >
   <intent-filter>
      <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
   </intent-filter>
 </receiver>

将以下主题添加到活动主题

android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

1 秒后打开你的意图,因为原来的拨出电话屏幕需要 800 毫秒才能打开,所以你需要覆盖那个屏幕,所以你必须在 800 毫秒后调用意图。这个对我有用。

于 2013-10-07T05:44:55.730 回答
0

The best way to do so is develop your own Phone app and expect the user to set it as the default app for making calls.

Edit:

Add an Activity which accepts ACTION_DIAL intent and have a numeric keypad and then once user has entered the call number, you can fire ACTION_CALL intent with the phone number which would invoke the native phone app. This way also, the user has to select your app to be set as default one for ACTION_DIAL intent.

于 2013-10-07T04:47:59.020 回答
0

您无需创建单独的应用程序。最终你只想处理新的呼出请求,所以创建一个BroadcastReceiver监听ACTION_NEW_OUTGOING_CALL的事件,并创建一个Activity调用该事件的事件。

您需要在清单文件中指定有关PROCESS_OUTGOING_CALLS的权限。

看看一些参考资料

处理电话呼叫请求的正确方式

安卓拨号器应用程序

我希望它会有所帮助!

于 2013-10-07T05:43:22.777 回答