I have created a small app in that user can able to answer the call, reject the call, and call back option while mobile screen is off so how to open my app when call is coming
I have tried this code :
public class BroadCast_Reciver extends BroadcastReceiver {
Context context;
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state != null && state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
Toast.makeText(context, "Call Incoming", Toast.LENGTH_SHORT).show();
String incomingCallerNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (incomingCallerNumber != null) {
Intent intent1 = new Intent(context, MainActivity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent1.putExtra("number", incomingCallerNumber);
context.startActivity(intent1);
}
}
}
}
can u give the proper solution for this ?