Android-无法在显示LayoutParams.TypeSystemError时看到来电 [英] Android - Cant see the incoming calls when LayoutParams.TypeSystemError is displayed
问题描述
我正在开发锁屏应用程序.使用此命令"WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;"将锁定屏幕显示在屏幕顶部.
I'm developing lock screen app. Here Lock screen is displayed on the top of the screen using this command "WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;"
但是我的问题是,显示自定义锁定屏幕时,我看不到来电窗口.自定义锁定屏幕不会覆盖来电窗口.
But my problem is I can't See the Incoming call Window when the custom lock screen is displayed. Incoming call window is not overrided over my custom lock screen.
1)显示来电窗口是否需要任何权限??
1) Is there any permission required for displaying the incoming call window.?
2)我们必须添加任何其他代码来回答传入的班级
2) We have to add any other codes for answering the incoming class
这是我的锁屏接收器课程
This is my Lockscreen receiver class
public class LockScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(action.equals(Intent.ACTION_SCREEN_OFF) || action.equals(Intent.ACTION_BOOT_COMPLETED))
{
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
在常规锁定屏幕应用程序中->他们可以参加传入的呼叫,并且在参加该呼叫之后,将显示锁定屏幕.怎么样????
In the normal lock screen apps -> They can attend the incoming calls and after attending that call, lock screen is displayed. How ????
请帮助我.预先感谢
推荐答案
-
在清单中添加接收者并寻求许可
Add receiver in the manifest and ask for permission
<receiver android:name=".IncomingCall">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
< uses-permission android:name ="android.permission.READ_PHONE_STATE"></uses-permission>
创建类 IncomingCall
public class IncomingCall extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
TelephonyManager telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
MyPhoneStateListener PhoneListener = new MyPhoneStateListener();
// Register listener for LISTEN_CALL_STATE
telephonyManager.listen(PhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
} catch (Exception e) {
e.printStackTrace();
}
在 LockScreen
中实现 PhoneStateListener
并调用 onCallStateChanged
private class LockScreen extends AppCompatActivity implements PhoneStateListener{
public void onCallStateChanged(int state, String incomingNumber) {
//Disable lockscreen when calls come
}
这篇关于Android-无法在显示LayoutParams.TypeSystemError时看到来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!