How to add a popup window over an Android native incoming call screen like the Truecaller Android app
My broadcast reciver
- package com.example.popwindowonincomingcallscreen;
- import java.util.concurrent.Executors;
- import java.util.concurrent.ScheduledExecutorService;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.telephony.TelephonyManager;
- import android.util.Log;
- public class IncomingBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d("IncomingBroadcastReceiver: onReceive: ", "flag1");
- String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
- Log.d("IncomingBroadcastReceiver: onReceive: ", state);
- if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)
- || state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
- Log.d("Ringing", "Phone is ringing");
- Intent i = new Intent(context, IncomingCallActivity.class);
- i.putExtras(intent);
- i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- Wait.oneSec();
- context.startActivity(i);
- }
- }
- }
An the activity which I am calling
- import android.app.Activity;
- import android.os.Bundle;
- import android.telephony.TelephonyManager;
- import android.util.Log;
- import android.view.View.MeasureSpec;
- import android.view.Window;
- import android.view.WindowManager;
- import android.widget.TextView;
- public class IncomingCallActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- try {
- Log.d("IncomingCallActivity: onCreate: ", "flag2");
- */After this line code is not executed in jelly bean only/*
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
- getWindow().addFlags(
- WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
- Log.d("IncomingCallActivity: onCreate: ", "flagy");
- setContentView(R.layout.main);
- Log.d("IncomingCallActivity: onCreate: ", "flagz");
- String number = getIntent().getStringExtra(
- TelephonyManager.EXTRA_INCOMING_NUMBER);
- TextView text = (TextView) findViewById(R.id.text);
- text.setText("Incoming call from " + number);
- } catch (Exception e) {
- Log.d("Exception", e.toString());
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Articoli simili
- C'è qualche lettore video disponibile per altri dispositivi Android che dà la caratteristica come Smart Pause e Popup Window di Samsung?
- A small, free-falling pebble takes 0.25 s to pass by a window 1.8m high. From what height above the window was the pebble dropped?
- Qual è la differenza tra call tracking, call metrics e call analytics?
- Posso costruire app native per Android e iOS usando React Native?