Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't use dialog on BroadcastReceiver, so instead you better call an activity for the dialog box from the BroadcastReceiver, </p> <p>add this code in your onReceive function : </p> <pre><code>@Override public void onReceive(Context context, Intent intent) { Intent i = new Intent(context, {CLASSNAME}.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } </code></pre> <p>fill the {CLASSNAME} with the dialog activity, heres my dialog activity : </p> <pre><code>package com.example.mbanking; import android.os.Bundle; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; // ALERT DIALOG // Sources : http://techblogon.com/alert-dialog-with-edittext-in-android-example-with-source-code/ public class AlertDialogActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle("Test") .setMessage("Are you sure you want to exit?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } } </code></pre> <p>where I got the answer ?, here : <a href="https://stackoverflow.com/questions/6172088/how-do-you-use-an-alert-dialog-box-in-a-broadcast-receiver-in-android">How do you use an alert dialog box in a broadcast receiver in android?</a> thanks to Femi !!, I just spread the news :D</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload