Development issue/problem:

I’m developing a receiver for incoming calls on Android and when I receive incoming calls, I want a pop-up window to appear on the screen for incoming calls domestically.

I entered this code. But now the problem is that in Android 4.1 (Jelly Bean) API layer 17, when the phone rings, PHONE_STATE is displayed as OFF HOOK, and when I call an activity, it is called, but no code is output below it. I’ll figure out the code:

com.example.popwindowonincomingcallscreen package ;

Import java.util.competitor.Executors;
Import java.util.competitor.ScheduledExecutorService ;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.intention;
import android.telephonyManager;
import android.util.Log ;

public class IncomingBroadcastReceiver expands BroadcastReceiver {

@Define
to receive the public void (context, intention) {.

Log.d (Incoming Broadcast Receiver: onReceive: , flag1) ;

State of the string = intent.getStringExtra(TelephonyManager.EXTRA_STATE) ;
Log.d(IncomingBroadcastReceiver: onReceive: , state) ;
if (state.equals(TelephonyManager.EXTRA_STATE_RING)
| state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {) {)

Log.d (ring tone, phone rings)

Intention i = new intention (context, IncomingCallActivity.class);i.putExtras(intention);i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);Wait.oneSec();context.startActivity(i);}}}}

An activity I call:

import android.app.Activity;
import android.os.bundle;
import android.phone.phoneManager;
import android.util.Log;
import android.view.MeasureSpec;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView ;

the public class IncomingCallActivity expands the activity {

@Override
protected empty onCreate(Bundle storedInstanceState) {

try {
Log.d(IncomingCallActivity: onCreate: , flag2) ;

*/ After this line, the code will not only be executed in Android 4.1 (Jelly Bean)/*.

// TODO Automatically generated method heel
super.onCreate (savedInstanceState) ;

getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL) ;
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL) ;

Log.d(IncomingCallActivity: onCreate: , flagy) ;

setContentView(R.layout.main) ;

Log.d (IncomingCallActivity: onCreate: , flagz) ;

LineNumber = getIntent().getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);TextView text = (TextView) findViewById(R.id.text);text.setText (Incoming call from + number);}-call (Exception e) {Log.d(Exception, e.toString());// TODO-generated automatic blocking.printStackTrace();}}}}

According to

try {
Log.d(IncomingCallActivity: onCreate: , flag2);
}

The code does not work on Android 4.1 (Jelly Bean), but in other versions.

I’ve tried almost everything. This indicator shows a translucent activity on the original call screen and does not block background checks such as. B. By picking up the horn. But I want it to be a real phone call. I have added an example of how the actual caller displays the incoming call window.

How do I get this feature for an Android application?

That’s how a real interlocutor works:

My current release:

I’m not looking for generosity either, but I’ll get back to everything. I’m working on it. In any case, this code works for most Android phones. If someone uses the solution to this problem and catches it, post it here for everyone to enjoy.

I tried to run Toast in the onReceive method of the transceiver, because Toast is a native Android component, but it doesn’t appear in Android 4.1 either (Jelly Bean).

My idea was to implement Toast in the onReceive method of the broadcast receiver, then adapt the design to our needs and change the display time. But another problem is that findViewById doesn’t work in the transceiver, so I think we should do LinearLayout programmatically to match the toast.

How can I solve this problem?

Solution 1:

I am not sure that your custom GUI will always be above the standard GUI because the system receiver and your receiver will try to display their GUI at the top of the screen. We don’t know exactly which one will be called first, but one of the difficulties to make your GUI appear at the top of the screen is that when the phone rings after 1 to 2 seconds, a manager is used to do this.

new Handler().postDelayed(new Runnable()) {

@Override
public void run() {
// TODO auto-generation method stub
Intent intent = new intent (context, AcceptReject.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}, 2000) ;

I hope this helps.

Solution 2:

Try the code for the super.onCreate method. I think the code’s missing after the supervisor called. Sometimes that kind of trick worked for me.

Solution 3:

I just tested it on an Android 4.2 emulator (Jelly Bean) and it works perfectly, blocks the whole screen for incoming calls just like Truecaller :

public disability reception (background, intention) {

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE) ;

WindowManager.LayoutParams settings = new WindowManager.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSPARENT) ;

params.height = LayoutParams.MATCH_PARENT ;
params.width = LayoutParams.MATCH_PARENT ;
params.format = PixelFormat.TRANSLUCENT ;

Parameter.gravity = gravity.high;

LinearLayout ly = new LinearLayout(context) ;
ly.setBackgroundColor(Color.RED) ;
ly.setOrientation(LinearLayout.VERTICAL) ;

wm.addView(ly, params);
}

In the manifesto:

Solution 4:

I’m working on it too (maybe I misunderstand you). What you want is to display this activity in Android 4.2 (Jelly Bean). I just posted a deadline for the activity. I have used PhoneStateListener in several courses. I see the new activities on the caller’s screen. Here’s my full code:

Give here a description of the image

MyBroadcastReceiver.java file

The MyBroadcastReceiver public class expands BroadcastReceiver {
static CustomPhoneStateListener phoneStateListener;
Context context;
Intention ;

@Overrider
public void onReceive(Context context, intention) {
this.context = context;
this.intent = intention;
// TODO Automatically generated stretching method

TelephonyManager phoneManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);phoneStateListener = new CustomPhoneStateListener(context);telephonyManager.listener,PhoneStateListener.LISTEN_CALL_STATE);}}}.

CustomPhoneStateListener.java file

The CustomPhoneStateListener public class extends the PhoneStateListener {

// Private Static Final String TAG = PhoneStateChanged;
Context Context; // Context to toast on request
Private AudioManager amanager;
Intention i1 ;

public CustomPhoneStateListener(Context context) {
super();
this.context = context;
i1 = new Intent(context, YourActivity.class);
i1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) ;

}

Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber) ;

switch (status) {
case TelephonyManager.CALL_STATE_IDLE :
Toast.makeText(context, Phone Status Idle, Toast.LENGTH_LONG)
.show() ;

pause;
case TelephonyManager.CALL_STATE_OFFHOOK :

Toast.makeText(context, Phone status suspended, Toast.LENGTH_LONG)
.show() ;

pause;
case TelephonyManager.CALL_STATE_RING:
attempt {
Thread.sleep(3000);
context.startActivity(i1);
} catch (Exception e) {
e.getLocalizedMessage();
}

default:
pause;
}
}

and your company will remain as you created it….
Pay attention: I’m having some trouble with this code too, they’re here.

  1. If a closed call is not completed (missed or rejected), the activity is not completed.
  2. I cannot click on the activity (I want to place a button for my application).
  3. It only works the first time. When I make a second call, the application stops (I think this is because the activity does not close when the call is disconnected).

(Help is accepted for these problems. Thank you very much. Maybe you can help someone.)

FIXED

HERE’S A LINK TO A LITTLE DEMONSTRATION ON HOW TO DO IT.

  1. If a closed call is not completed (missed or rejected), the activity is not completed. – DISSOLVED
  2. I cannot click on the activity (I want to put a button on it for my request) – SOLUTIONS
  3. It only works the first time. If I make a second call, my application is closed (I think this is because the activity is not closed when the call is aborted) – Cleared up

Solution No 5:

I don’t think it’s necessary to start an activity to achieve the result described. You need a separate view with LayoutParams.TYPE_SYSTEM_OVERLAY in the layout parameters.

You can place this view anywhere on the screen or just cover the whole screen.

Here are a few lines of code:

av = new ActivatorView(this);_avLayoutParams = new WindowManager.LayoutParams(0, 0, 0,WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,PixelFormat.OPAQUE);_avLayoutParams.screenBrightness= _fScreenBrightness= 2

WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE) ;
wm.addView(_av, _avLayoutParams) ;

https://bitbucket.org/gyrussolutions/yaab/src/f01cc8aff690cae1b1107287cb17835b8a3c1643/src/biz/gyrus/yaab/LightMonitorService.java?at=default#cl-338 – the complete source code, consider it as an example.

Solution No 6:

I try to do something similar by adding an extra button to the incoming call screen.

The answer Sam Adams put on the site is fine for me, even if I call the PhoneStateListener code. Besides, the only real difference in his code is that I blow up the layout:

overlay = (RelativeLayout) inflater.inflate(R.layout.overlay, null);
wm.addView(overlay, parameters) ;

It works on emulators as well as the HTC One S (with Android 4.1.1).

You must have a reference to the view of the overlay you are adding and removing (call removeView() on the windowmanager instance) when the phone goes back to standby (when the listener receives TelephonyManager.CALL_STATE_IDLE), otherwise your overlay will remain on the screen.

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if(overlay!=null)
{
wm.removeView(overlay);
overlay = null;
}

Solution No 7:

We also encountered a similar problem, namely that the overlay is not displayed on a pinlock device. The solution that worked for us can be found below:

mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT,
LayoutParams.TYPE_SYSTEM_ERROR,
LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT) ;

The difference was in LayoutParams.TYPE_SYSTEM_ERROR.

Solution No 8:

Try this

AlertDialog.Builder builder = new AlertDialog.Builder(context.getApplicationContext());
LayoutInflater inflater = LayoutInflater.from(context);
View dialogView = inflater.inflate(R.layout.caller_dialog, null);
ImageView button = dialogView.findViewById(R.id.close_btn);
builder.setView(dialogView);
last AlertDialog alert = builder.create();
alert.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
alert.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
alert.setCanceledOnTouchOutside(true);
alert.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
window = alert.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
window.clearFlags(WindowManager).LayoutParams.FLAG_DIM_BEHIND);
window.setGravity(Gravity.TOP);
lp.copyFrom(window.getAttributes());
//T This makes the full width dialog
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Close service and remove from window
alert.dismiss();
}
}) ;

Solution No 9:

My method:

  1. Use the handset to receive calls
  2. use the service to create an overlay

ps:wmParams.type = WindowManager.LayoutParams.TYPE_PHONE ;

Solution No 10:

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// TODO auto-generation method stub
Intent i = new Intent (context, CallingIncoming).class);
i.putExtras(int);
i.addFlags(intent.).FLAG_ACTIVITY_NEW_TASK /*| Intent.FLAG_ACTIVITY_CLEAR_TASK*/);
context.startActivity(i);
}
}, 450);//Es will help you keep your screen and your screen will then be the default search screen above.

Good luck!

android popup over incoming-call screen,android incoming call screen source code,android overlay incoming call screen,android incoming call screen github,show dialog on incoming call android like truecaller,custom incoming/outgoing call screen in android github,truecaller popup android,truecaller android source code,how to receive incoming call in android programmatically,how to get caller name in android programmatically,custom incoming/outgoing call screen in android example

You May Also Like

Malicious Bots – What Are They and How Can You Avoid Them? •

As the name suggests, malicious bots are software programs that are designed…

How to Root Sony Xperia M2 (Eagle) and Install TWRP Recovery 3.5.0

If you own a Sony Xperia M2 and want to install TWRP…

Upgrade your PC to Windows 10 version 21H1 (May 2021 Update) for free

Windows 10 version 21H1 (May 2021 Update) is now available to all…

File system error 1073741515 in Windows 10

What causes registration errors? Registration errors occur mainly when new applications are…