QNA > H > How To Add A Popup Window Over An Android Native Incoming Call Screen Like The Truecaller Android App

How to add a popup window over an Android native incoming call screen like the Truecaller Android app

My broadcast reciver

  1. package com.example.popwindowonincomingcallscreen; 
  2. import java.util.concurrent.Executors; 
  3. import java.util.concurrent.ScheduledExecutorService; 
  4. import android.content.BroadcastReceiver; 
  5. import android.content.Context; 
  6. import android.content.Intent; 
  7. import android.telephony.TelephonyManager; 
  8. import android.util.Log; 
  9. public class IncomingBroadcastReceiver extends BroadcastReceiver { 
  10. @Override 
  11. public void onReceive(Context context, Intent intent) { 
  12. Log.d("IncomingBroadcastReceiver: onReceive: ", "flag1"); 
  13. String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); 
  14. Log.d("IncomingBroadcastReceiver: onReceive: ", state); 
  15. if (state.equals(TelephonyManager.EXTRA_STATE_RINGING) 
  16. || state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { 
  17. Log.d("Ringing", "Phone is ringing"); 
  18. Intent i = new Intent(context, IncomingCallActivity.class); 
  19. i.putExtras(intent); 
  20. i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
  21. i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
  22. Wait.oneSec(); 
  23. context.startActivity(i); 

An the activity which I am calling

  1. import android.app.Activity; 
  2. import android.os.Bundle; 
  3. import android.telephony.TelephonyManager; 
  4. import android.util.Log; 
  5. import android.view.View.MeasureSpec; 
  6. import android.view.Window; 
  7. import android.view.WindowManager; 
  8. import android.widget.TextView; 
  9. public class IncomingCallActivity extends Activity { 
  10. @Override 
  11. protected void onCreate(Bundle savedInstanceState) { 
  12. try { 
  13. Log.d("IncomingCallActivity: onCreate: ", "flag2"); 
  14. */After this line code is not executed in jelly bean only/* 
  15. // TODO Auto-generated method stub 
  16. super.onCreate(savedInstanceState); 
  17. getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); 
  18. getWindow().addFlags( 
  19. WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); 
  20. Log.d("IncomingCallActivity: onCreate: ", "flagy"); 
  21. setContentView(R.layout.main); 
  22. Log.d("IncomingCallActivity: onCreate: ", "flagz"); 
  23. String number = getIntent().getStringExtra( 
  24. TelephonyManager.EXTRA_INCOMING_NUMBER); 
  25. TextView text = (TextView) findViewById(R.id.text); 
  26. text.setText("Incoming call from " + number); 
  27. } catch (Exception e) { 
  28. Log.d("Exception", e.toString()); 
  29. // TODO Auto-generated catch block 
  30. e.printStackTrace(); 
main-qimg-d817d656b5666d546424aa0ebcfd96f3

Di Lubin

Se Google è vietato in Cina, allora come fa la Cina a gestire Android? Android non è basato su Google? :: I processori desktop possono essere ottimizzati per gli smartphone?
Link utili