Update - May 09, 2013 * I tried to inject Toast into the onReceive broadcast receiver because the toast is a native component of Android, but it also does not appear in Android 4.1 (Jelly Bean).
My idea was to inject Toast into the onReceive broadcast receiver, and then change its design to suit our needs and adjust its display duration. But another problem is that findViewById does not work in the broadcast receiver, so I think we should make LinearLayout a programmatic way to set up the toast. *
Update . After generosity, I also do not receive what I seek, but I will return to all; I'm working on it. Anyway, this code works for most Android phones. If someone is going to use and catch a solution for this, write here so that everyone can benefit. Thanks for all your answers.
I am developing a broadcast receiver for incoming calls on Android and when incoming calls arrive that I want to inflate a pop-up window on my own incoming call screen.
I have completed this code. But now the problem is that in Android 4.1 (Jelly Bean) level API 17 , when the phone rings, PHONE_STATE approaches as an OFF HOOK , and if I call an action, it is called, but the code below it does not execute. I am listing the code:
My broadcast receiver
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); } } }
I perform the actions that I invoke:
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, the code is not executed in Android 4.1 (Jelly Bean) only
After
try { Log.d("IncomingCallActivity: onCreate: ", "flag2"); }
The code does not run in Android 4.1 (Jelly Bean), but in other versions it works.
I tried almost everything I can. This code displays a translucent activity on the own calls screen, and it does not block background controls, for example, picks up the phone. But I want him to be a true caller. I attached a snapshot of how the true caller displays a window on the incoming call screen.
How can I achieve this functionality for an Android app?
Here's how the true caller works:

My current output is:
