tags:

views:

1028

answers:

3

I am trying to debug something and want to pop up a message dialog box. Eclipse is telling me that it wants me to "Create Method showAlert(string, string, string, boolean)"

I have imported this import android.content.DialogInterface;

what step am I missing?

A: 

Looks like you might have a parameter-type mismatch. Check that your parameters are actually Strings or booleans. Maybe you need to be calling toString() on your objects?

Justin
Well, I've gone a different way...those are the parameters that were given from the other blog help page. So now I am using the AlertDialog builder from developer.android.com...have gotten past that error to this: [2010-02-01 13:41:12 - MobileServiceCallContacts]ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.msi.ibm.tutorial/.MobileServiceCallContacts } from null (pid=-1, uid=-1) requires android.permission.READ_CONTACTSand yes, I have that permission set in my manifest...where else is it supposted to go????
jkmcgee
You should open another question for that... but as far as I know, only place permissions need to be is in AndroidManifest.xml
Justin
+2  A: 

If you are trying to create and display an AlertDialog, you should user AlertDialog.Builder for example.

DialogInterface, is as its name implies, an interface and only has 2 methods: cancel() and dismiss().

Creating an AlertDialog is fairly easy:

new AlertDialog.Builder(this)
.setTitle("Some Title")
.setMessage("some message")
.setPositiveButton("OK", new OnClickListener() {
    public void onClick(DialogInterface arg0, int arg1) {
        // Some stuff to do when ok got clicked
    }
})
.setNegativeButton("cancel", new OnClickListener() {
    public void onClick(DialogInterface arg0, int arg1) {
        // Some stuff to do when cancel got clicked
    }
})
.show();

That shows a simple AlertDialog.

A tip: Check Activity.showDialog(int) and Activity.onCreateDialog() they make your life easier when using dialogs.

MrSnowflake
+1  A: 

If you are only showing a debug message you may try [Toast.makeText()][1]. Like in

Toast.makeText(context, "Hi there!", Toast.LENGHT_SHORT).show();

Don't forget the show().

[1]: http://developer.android.com/intl/fr/reference/android/widget/Toast.html#makeText(android.content.Context, java.lang.CharSequence, int)

dtmilano
Is there a way to add an acknowledge button to the Toast method? That's why I want to use the alert dialog method.
jkmcgee