Skip to content Skip to sidebar Skip to footer

Android - Cant See The Incoming Calls When Layoutparams.typesystemerror Is Displayed

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

Solution 1:

  1. Add receiver in the manifest and ask for permission

    <receiverandroid:name=".IncomingCall"><intent-filter><actionandroid:name="android.intent.action.PHONE_STATE" /></intent-filter></receiver>

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

  2. Create class IncomingCall

    publicclassIncomingCallextendsBroadcastReceiver {
    
    publicvoidonReceive(Context context, Intent intent) {
    
        try {
                TelephonyManagertelephonyManager= (TelephonyManager) context
                        .getSystemService(Context.TELEPHONY_SERVICE);
    
                MyPhoneStateListenerPhoneListener=newMyPhoneStateListener();
    
                // Register listener for LISTEN_CALL_STATE
                telephonyManager.listen(PhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
    
        } catch (Exception e) {
            e.printStackTrace();
        }
    
  3. Implement PhoneStateListener in LockScreen and call onCallStateChanged

    privateclassLockScreenextendsAppCompatActivityimplementsPhoneStateListener{
    
        publicvoidonCallStateChanged(int state, String incomingNumber) {
    
            //Disable lockscreen when calls come
    
        }
    

Post a Comment for "Android - Cant See The Incoming Calls When Layoutparams.typesystemerror Is Displayed"