显示在呼叫的中间信息 [英] show the information in the middle of the call
问题描述
我要显示在该屏幕如天气信息,或类似的Facebook更新呼叫中间的一些信息,任何人都可以帮助我。
I want to show some information in the middle of a call in that screen like weather info, or facebook updates like that, can anyone help me.
请参阅我想要的更新下面的截图。
See the screenshot below of the update that I want.
在此先感谢
推荐答案
检查该<一href="http://stackoverflow.com/questions/5948961/how-to-know-whether-i-am-in-a-call-on-android">stack 。在溢出的答案回答,你可以看到举杯显示,敬酒不同的呼叫states.Instead使自定义敬酒,并通过该自定义敬酒显示您的更新。
check this stack overflow answer.In that answer you can see a toast showing different call states.Instead of that toast make a custom toast and show your updates via that Custom toast.
如果你想展示活动,而不是敬酒试试这个code在CustomPhoneStateListener
if you want show an activity instead of toast try this code in your CustomPhoneStateListener
public class CustomPhoneStateListener extends PhoneStateListener {
ActivityManager activityManager;
Intent i1;
public CustomPhoneStateListener(Context context) {
super();
this.context = context;
i1 = new Intent(context, TelephoneyWithoutToastActivity.class);
i1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
//when Idle i.e no call
Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
//when Off hook i.e in call
//Make intent and start your service here
Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show();
break;
case TelephonyManager.CALL_STATE_RINGING:
ActivityManager localActivityManager = (ActivityManager) this.context.getSystemService("activity");
for (String str = ((ActivityManager.RunningTaskInfo) localActivityManager.getRunningTasks(1).get(0)).topActivity.flattenToString();; str = ((ActivityManager.RunningTaskInfo) localActivityManager.getRunningTasks(1).get(0)).topActivity.flattenToString()) {
if ((!str.contains("com.android.phone.InCallScreen")))
continue;
Log.d("IncomingCallPlus", "*****************************************************");
context.startActivity(i1);
return;
}
default:
break;
}
}
}
添加到您的活动的默认调用屏幕上的触摸激活。
add this to your activity for activating touch on the default calling screen.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
这个功能会给两个触摸屏来电和弹出
this function will give touch on both caller screen and popup
public void addInvitePopup(final String number, Context c) {
//check if pref is ok with invite in call
// if(!Preferences.getInstance(c.getInviteInCall())){return ; }
// sets the WindowManager
WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.x = 250;
params.height = LayoutParams.WRAP_CONTENT;
params.width = LayoutParams.WRAP_CONTENT;
params.format = PixelFormat.TRANSLUCENT;
final Context ct = c;
params.gravity = Gravity.TOP;
params.setTitle("Testing");
LinearLayout ly = new LinearLayout(c);
ly.setOrientation(LinearLayout.VERTICAL);
Button inviteButton = new Button(c);
inviteButton.setClickable(true);
inviteButton.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.ic_launcher));
inviteButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(v.getContext(), "adding to blacklist..", Toast.LENGTH_LONG).show();
v.setBackgroundDrawable(ct.getResources().getDrawable(R.drawable.images));
v.setClickable(false);
// sendMessage(v, number);
//Track this event:
//MixPanelTracking.setPropKeyValue(getApplicationContext(), null, null, "Add friend - During Call");
}
});
inviteButton.setWidth(30);
inviteButton.setHeight(30);
// inviteButton.setLayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
// WindowManager.LayoutParams.WRAP_CONTENT);
ly.addView(inviteButton);
wm.addView(ly, params);
// wm.addView( inviteButton, params);
Log.i("TTT", "after add view");
}
在清单文件中添加此权限
add this permission in manifest file
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
这篇关于显示在呼叫的中间信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!