Been trying to get my app to go back to the main activity when a user touches the OK button inside an AlertDialog
.
The alert dialog I show is basically an error message to inform the user that no data was found for a specific date they chose and called in an activity that is NOT the main activity but I want them sent back to the main one when they click OK.
The call runs fine, its just that it seems to not know how to find the Main Activity even though the call I am using works in any normal activity.
The error
I get is:
1554-1554/org.springframework.android.showcase2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=org.springframework.android.showcase2.MainActivity }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
Specific AlertDialog code is:
package org.springframework.android.showcase2;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MyAlertDialogFragment extends DialogFragment {
private String title;
private String message;
private TextView tvError;
public MyAlertDialogFragment(String sTitle, String sMessage){
this.title = sTitle;
this.message = sMessage;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(this.title)
.setMessage(this.message)
.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// This is the way I nomally call a new activity inside other activities but seems to not work inside this AlertDialog scope
Intent i = new Intent("org.springframework.android.showcase2.MainActivity");
startActivity(i);
}
}
)
.create();
}
}