Show alert in present activity by other device using a Bluetooth chat example
<p>I am developing a Bluetooth chat application with the help of the Bluetooth chat application on the Android developer site.</p>

<p>I did some modifications in existing code as when I send Bluetooth chat requests to another device (assume we are paired previously) and request receiving device resides in any activity.</p>

<p>I want to display an alert to the current displaying screen, but I am getting an alert at a particular activity only. So I am getting stuck. My code is below for the sender and receiver side:</p>

<pre><code>if (FaceCardList.requestConnection &amp;&amp;
    FaceCardList.deviceSelected) {

    String authorization = "messagetype:startChat,"
                            + FaceCardList.ScreenName;
    FaceCardList.this.sendMessage(authorization);
}
</code></pre>

<p>On the receiving side:</p>

<pre><code>if (readMessage.indexOf("messagetype:startChat") != -1) {

    AlertDialog.Builder builder =
        new AlertDialog.Builder(FaceCardList.this);
    builder.setMessage(
        FaceCardList.screennmname + " wants to chat with you")
        .setCancelable(false)
        .setPositiveButton("Yes",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface arg0, int arg1) {
                    Intent serverIntent = new Intent(
                            FaceCardList.this,
                            BluetoothChat.class);
                    startActivity(serverIntent);

                    String authorization = "messagetype:initiatechat";
                    FaceCardList.this
                            .sendMessage(authorization);
                }
            })
        .setNegativeButton("No",
            new DialogInterface.OnClickListener() {

                public void onClick(
                        DialogInterface diaLog,
                        int which) {
                    // TODO Auto-generated method stub

                    String authorization = "messagetype:stopservice";
                    FaceCardList.this
                            .sendMessage(authorization);

                    FaceCardList.mChatService.stop();
                    FaceCardList.mChatService.start();
                }
            });
    alert = builder.create();
    alert.show();
</code></pre>
