开发者

How to show dialog during the Receiver?

开发者 https://www.devze.com 2023-03-18 05:27 出处:网络
I want to show the dialog during the Receiver , i used this code but it\'s not true, can anyone help me?

I want to show the dialog during the Receiver , i used this code but it's not true, can anyone help me?

public class Call_Sevice extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
String number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)){
AlertDialog.Builder builder = new AlertDialog.Buil开发者_Go百科der(this);
builder.setTitle("Message");
builder.setMessage("Its Ringing [" + number + "]");
builder.setNeutralButton("Confrim", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id){
System.exit(0);
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
}

Thanks


You cannot "show the dialog during the Receiver". You can create an Activity that is themed to look like a dialog (Theme.Dialog) and start that activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消