How to handle exceptions in enduser friendly way

I am developing an android app where I am dealing with sending and receiving information to and from our servers.Please let me know when any sort of exception occurs I am trying to show an alertbox, but the issue is that the alert box is not displayed always. Please help me with a solution so that when ever an exception takes place some sort of friendly UI is to be displayed. The AlertBox I am using

public  void Alertbox(String title, String mymessage,Context context ) {
    new AlertDialog.Builder(context)
    .setMessage(mymessage)

    .setCancelable(true)
    .setNeutralButton(android.R.string.ok,new DialogInterface.OnClickListener()

    {
        public void onClick(DialogInterface dialog,int whichButton) {



        }
    }).show();
}

public static void ProcessDialogue(String title,Context context)
{


}

Answers


Create ErrorBroadcastReceiver and Error ACTION with Extras string.

public class ErrorReceiver extends BroadcastReceiver {
    public static final String ERROR_ACTION = "com.yourpackage.ERROR_ACTION";
    public static final String ERROR_MESSAGE = "ERROR_MESSAGE"; 

    @Override
    public void onReceive(Context context, Intent intent) {
        String errorMessage = intent.getStringExtra(ERROR_MESSAGE);     
        Toast.makeText(context, errorMessage, Toast.LENGTH_SHORT).show();
    }

}

and send broadcast intents to this receiver

 Intent errorIntent = new Intent(ERROR_ACTION);
        errorIntent.putExtra(ERROR_MESSAGE , e.getMessage());// exception from try/catch block or your custom error type
        sendBroadcast(errorIntent)

Need Your Help

Triggering a javascript function every two hours

javascript jquery google-chrome-extension

I'm making a chrome extension. I need to trigger a javascript function every two hours. It is possible to do it with;

Capturing audio out for use in a web page

audio scripting web out

I am wondering if it is possible, using JavaScript, php, or any other method to capture general 'audio out' or line out, and send it to be used in a web page.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.