Reputation: 55
I'm using a cusom dialog box in the mainActivity of my project... it was perfectly working, but, now i got an error message when i trying to use that class.
The error is like this:
The method onCreate(bundle) of type MainActivity must override or implement a supertype method
the code is giving below... anyone know the problem?? please help me...
package MainPRJ.Diary;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import android.R.string;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Contacts.Settings;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
//This means the baseline (MDPI) asset is 48x48 px, and the high density (HDPI) asset should be 1.5x the baseline at 72x72 px, and the x-high density (XHDPI) asset should be 2x the baseline at 96x96 px, and so on.
public class MainPRJ extends Activity {
/** Called when the activity is first created. */
EditText e1;
ImageView ok,t5,t6;
DBManager dbManager;
Context cont=this;
ArrayList<Object> arl=null;
Boolean f;
int flag=0;
String str;
settings st;
boolean checkcontent;
connectionDetector cd;
Boolean isInternetPresent = false;
static Integer c=3;
/*ArrayList<Object> arrHint;
Context context=this;
ArrayList< Object> arPswd;*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
st=new settings();
t5=(ImageView) findViewById(R.id.text5);
t6=(ImageView) findViewById(R.id.text6);
e1=(EditText) findViewById(R.id.editText1);
ok=(ImageView) findViewById(R.id.login_ok);
dbManager=new DBManager(this);
cd = new connectionDetector(getApplicationContext());
checkcontent=dbManager.getavailability();
if(checkcontent)
{
t5.setImageResource(R.drawable.userdetail);
t6.setVisibility(View.VISIBLE);
e1.setVisibility(View.VISIBLE);
ok.setVisibility(View.VISIBLE);
flag=1;
//t5.setEnabled(false);
}
else
{
t6.setVisibility(View.INVISIBLE);
e1.setVisibility(View.INVISIBLE);
ok.setVisibility(View.INVISIBLE);
}
ok.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(e1.getText().toString().equals(""))
{
Toast.makeText(getApplicationContext(), "Enter the password", 5000).show();
}
else
{
arl=dbManager.retrievePswdAsArray();
if(e1.getText().toString().equals((String)arl.get(0)))
{
Intent i1=new Intent(getApplicationContext(), first_page.class);
startActivity(i1);
arl.clear();
}
else
{
Toast.makeText(getApplicationContext(), "Password Incorrect", 5000).show();
}
}
//Toast.makeText(getApplicationContext(), (String)arl.get(0), 3000).show();
}
});
t5.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
//checkcontent=dbManager.getavailability();
//if(checkcontent)
if(flag==1)
{
//t5.setText("User Details");
Intent int3=new Intent(getApplicationContext(), userinfoshow.class);
startActivity(int3);
//t5.setEnabled(false);
}
else
{
Intent int2=new Intent(getApplicationContext(), user_information.class);
startActivity(int2);
}
}
});
t6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
isInternetPresent = cd.isConnectingToInternet();
arl= dbManager.retrievePswdAsArray();
final String pass=(String)arl.get(0);
arl.clear();
arl=dbManager.retrieveHintAsArray();
final String hint=(String)arl.get(0);
arl.clear();
final Dialog mdialog = new Dialog(MainPRJ.this);
mdialog.setContentView(R.layout.forgot_pswd_dialog);
mdialog.setCanceledOnTouchOutside(true);
final ViewHolder holder = new ViewHolder();
mdialog.setTitle("Password Access");
holder.OK = (Button) mdialog.findViewById(R.id.frgtOk);
holder.CANCEL= (Button) mdialog.findViewById(R.id.frgtCancel);
holder.HINT_ANS = (EditText) mdialog.findViewById(R.id.frgtHint);
holder.CAUTION = (TextView) mdialog.findViewById(R.id.frgtCaution);
mdialog.show();
holder.OK.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(holder.HINT_ANS.getText().toString().equalsIgnoreCase(hint))
{
Toast.makeText(getApplicationContext(), hint+" "+pass, 3000).show();
if (isInternetPresent)
{
ArrayList< Object> arrEmail= dbManager.retrieveDetailsAsArray();
String name=(String)arrEmail.get(0);
final String mail = (String) arrEmail.get(6);
final String content = "Hai "+name+"\n Your security password is : "+pass+"\n\n\n\n\n Regards...AuFriDis";
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try
{
sendMail(mail, content);
}
catch (Exception e) {
// TODO: handle exception
}
}
});
t.start();
mdialog.dismiss();
}
else
{
showAlertDialog(MainPRJ.this, "No Internet Connection",
"Password cannot be sent to mail address...", false);
}
}
else
{
c--;
if(c>0)
{
holder.CAUTION.setText("Incorrect Hint Answer \n"+c+" more try...");
}
else if(c==0)
{
if (isInternetPresent)
{
Toast.makeText(getApplicationContext(), "Your hint answer is send to mail address", 3000).show();
ArrayList< Object> arrEmail= dbManager.retrieveDetailsAsArray();
String name=(String)arrEmail.get(0);
final String mail = (String) arrEmail.get(6);
arrEmail.clear();
arrEmail=dbManager.retrieveHintAsArray();
String hint=(String)arrEmail.get(0);
final String content = "Hai "+name+"\n Your security question is : Nickname of your childhood friend\n Your security answer is : "+hint+"\n\n\n\n\n Regards...AuFriDis";
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try
{
sendMail(mail, content);
}
catch (Exception e) {
// TODO: handle exception
}
}
});
t.start();
c=3;
mdialog.dismiss();
}
else
{
showAlertDialog(MainPRJ.this, "No Internet Connection",
"Security Answer cannot be sent to mail address...", false);
}
}
}
}
});
holder.HINT_ANS.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
holder.CAUTION.setText("");
}
});
holder.CANCEL.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mdialog.dismiss();
}
});
}
});
}
Thanks in advance..
Upvotes: 0
Views: 6272
Reputation: 23873
The error reported refers to 'MainActivity', where is it? You have posted code for the class MainPRJ.
Also (although not responsible for the error) package names should be in lower case, like: com.yourname.yourproject.
Upvotes: 0
Reputation: 204
Your project's java version may be changed to 1.5 somehow. Try changing it to 1.6.
Go to
Properties -> JDK Compiler -> Select "1.6" from the Compiler compliance level dropdown (Android only supports 1.5 and 1.6, it does not yet support 1.7)
Upvotes: 1