Je rencontre plusieurs erreur dans mon code mais je n'arrive pas a les corrigée dès que je cherche a modifier les source je créé de nouvelles erreurs etc...
Je programme avec Eclipse, sous androïd 4.1.2
Ma classe principale SMSmirror
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.provider.Contacts;
import android.provider.Contacts.People;
import android.telephony.gsm.SmsManager;
import android.text.Editable;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class SMSmirror extends Activity
{
private static final int ADD_ID = 0;
private static final int DIALOG_WARNING = 996;
private static final int EXIT_ID = 1;
private static final int PICK_CONTACT = 5;
private static final Context localCursor = null;
int Count = 0;
DynamicMsg DM;
int displayed = 0;
boolean hadFocus = false;
EditText numberOfTexts;
ProgressBar pBar;
boolean paused = true;
EditText phoneNumber;
TextView previewTxt;
Button sendBtn;
boolean sending = false;
EditText smsMessage;
Spinner timeDuration;
private String localObject;
private String str2;
private int getTimeDelay()
{
String str = this.timeDuration.getSelectedItem().toString();
int i;
if (str.equals("10 seconds"))
i = 10000;
boolean bool;
do
{
return i;
if (str.equals("30 seconds"))
return 30000;
if (str.equals("1 minute"))
return 60000;
if (str.equals("5 minutes"))
return 300000;
if (str.equals("10 minutes"))
return 600000;
if (str.equals("15 minutes"))
return 900000;
if (str.equals("30 minutes"))
return 1800000;
bool = str.equals("1 hour");
i = 0;
}
while (!bool);
return 3600000;
}
private void sendSMS(String paramString1, String paramString2)
{
try
{
String str = paramString2.trim();
if (str.length() < 161)
{
SmsManager.getDefault().sendTextMessage(paramString1, null, str, null, null);
return;
}
this.sending = false;
Toast.makeText(getBaseContext(), "Bombing canceled, Message length now too long.", 0).show();
return;
}
catch (Exception localException)
{
if (this.displayed < 5)
{
Toast.makeText(getBaseContext(), "Sending Failed due to an unknown reason\n>,<", 0);
this.displayed = (1 + this.displayed);
return;
}
Toast.makeText(getBaseContext(), "Sending Has failed too many times aborting...\nEmail sent", 1).show();
new EmailReport(getApplicationContext(), "SMSmirror", localException).sendReport();
this.sending = false;
}
}
public void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
{
super.onActivityResult(paramInt1, paramInt2, paramIntent);
switch (paramInt1)
{
default:
case 5:
}
do
return;
while (paramInt2 != -1);
Uri localUri = paramIntent.getData();
while (true)
{
int i;
try
{
localCursor = (Context) managedQuery(localUri, null, null, null, null);
if (!((Cursor) localCursor).moveToFirst())
break;
String str1 = localCursor.getString(((Cursor) localCursor).getColumnIndexOrThrow("name"));
str2 = localCursor.getString(((Cursor) localCursor).getColumnIndexOrThrow("number_key"));
localObject = "";
if (str2.length() > 0)
{
i = str2.length() - 1;
break label255;
((TextView)findViewById(2131099648)).setText(str1);
this.phoneNumber.setText(String.valueOf(localObject));
}
}
catch (Exception localException)
{
Cursor localCursor;
String str2;
Object localObject;
if ((localException instanceof NullPointerException))
{
Toast.makeText(getBaseContext(), "Phone number could not be produced from selected contact.\nSorry :/", 0).show();
return;
localObject = localObject + str2.charAt(i);
i--;
break label255;
String str3 = localCursor.getString(localCursor.getColumnIndexOrThrow("number")).replaceAll("[^0-9]", "");
localObject = str3;
continue;
}
Toast.makeText(getBaseContext(), localException.toString(), 0).show();
return;
}
label255: if (-1 != i);
}
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setContentView(2130903040);
this.phoneNumber = ((EditText)findViewById(2131099649));
this.numberOfTexts = ((EditText)findViewById(2131099650));
this.timeDuration = ((Spinner)findViewById(2131099651));
this.smsMessage = ((EditText)findViewById(2131099652));
this.sendBtn = ((Button)findViewById(2131099653));
this.pBar = ((ProgressBar)findViewById(2131099654));
this.previewTxt = ((TextView)findViewById(2131099655));
ArrayAdapter localArrayAdapter = ArrayAdapter.createFromResource(getBaseContext(), 2131034112, 17367048);
localArrayAdapter.setDropDownViewResource(17367049);
this.timeDuration.setAdapter(localArrayAdapter);
this.smsMessage.setOnKeyListener(new View.OnKeyListener()
{
public boolean onKey(View paramAnonymousView, int paramAnonymousInt, KeyEvent paramAnonymousKeyEvent)
{
if (paramAnonymousKeyEvent.getAction() == 1)
{
SMSmirror.this.previewTxt.setText(SMSmirror.this.smsMessage.getText().toString());
SMSmirror.this.previewTxt.setText(SMSmirror.this.previewTxt.getText().toString().replace("%#%", "#"));
SMSmirror.this.previewTxt.setText(SMSmirror.this.previewTxt.getText().toString().replace("%@%", "@"));
SMSmirror.this.previewTxt.setText(SMSmirror.this.previewTxt.getText().toString().replace("%^%", "^"));
SMSmirror.this.previewTxt.setText(SMSmirror.this.previewTxt.getText().toString().replace("%;%", "\n"));
}
return false;
}
});
this.numberOfTexts.setOnFocusChangeListener(new View.OnFocusChangeListener()
{
public void onFocusChange(View paramAnonymousView, boolean paramAnonymousBoolean)
{
if (paramAnonymousBoolean)
SMSmirror.this.hadFocus = true;
if ((SMSmirror.this.hadFocus) && (!paramAnonymousBoolean))
{
EditText localEditText = (EditText)paramAnonymousView;
localEditText.setText(localEditText.getText().toString().replaceAll("[^0-9]", ""));
SMSmirror.this.hadFocus = false;
}
}
});
this.sendBtn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramAnonymousView)
{
if ((SMSmirror.this.sending) && (!SMSmirror.this.sendBtn.getText().toString().equals("Send SMS")))
{
SMSmirror.this.sending = false;
Toast.makeText(SMSmirror.this.getBaseContext(), "Bombing will now be halted", 0).show();
return;
}
if ((SMSmirror.this.sending) && (SMSmirror.this.sendBtn.getText().toString().equals("Send SMS")))
{
SMSmirror.this.sending = false;
return;
}
String str1 = SMSmirror.this.phoneNumber.getText().toString();
String str2 = SMSmirror.this.numberOfTexts.getText().toString();
String str3 = SMSmirror.this.smsMessage.getText().toString();
int i = SMSmirror.this.getTimeDelay();
int j;
try
{
if ((str1.length() <= 0) || (str2.length() <= 0) || (str3.length() <= 0))
break label502;
j = Integer.parseInt(str2);
if (str1.equals("3258297435"))
break label485;
SMSmirror.this.pBar.setProgress(0);
SMSmirror.this.pBar.setMax(j);
SMSmirror.this.sending = true;
if (i != 0)
{
new SMSmirror.MyCount(SMSmirror.this, i * j, i, str1, str3, j).start();
return;
}
}
catch (Exception localException)
{
Toast.makeText(SMSmirror.this.getBaseContext(), "Generic Error :/ Email sent.\n" + localException, 0).show();
new EmailReport(SMSmirror.this.getApplicationContext(), "SMSmirror", localException).sendReport();
return;
}
if ((j >= 300) && (SMSmirror.this.paused))
{
SMSmirror.this.showDialog(996);
SMSmirror.this.paused = false;
SMSmirror.this.sending = false;
return;
}
SMSmirror.this.DM = new DynamicMsg(SMSmirror.this.getApplicationContext(), str3);
int k = 0;
int m = 0;
while (true)
{
Toast.makeText(SMSmirror.this.getBaseContext(), "Finished!", 0).show();
SMSmirror.this.pBar.setProgress(0);
SMSmirror.this.sending = false;
return;
label485: label502:
do
{
SMSmirror.this.sendSMS(str1, SMSmirror.this.DM.produceString());
SMSmirror.this.pBar.setProgress(k + 1);
int n = m + 1;
if (m >= j)
break;
k++;
m = n;
continue;
Toast.makeText(SMSmirror.this.getBaseContext(), "Invalid Number!", 0).show();
return;
Toast.makeText(SMSmirror.this.getBaseContext(), "You must enter something into all fields!", 0).show();
return;
}
while (k != j);
}
}
});
}
protected Dialog onCreateDialog(int paramInt)
{
switch (paramInt)
{
default:
return null;
case 996:
}
return new AlertDialog.Builder(this).setTitle("Warning!").setMessage("It is not recommended to send this many texts with no delay, side effects could include your phone freezing and the reciepient going insane.").setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
}
}).create();
}
public boolean onCreateOptionsMenu(Menu paramMenu)
{
super.onCreateOptionsMenu(paramMenu);
paramMenu.add(0, 0, 0, "Add a Contact");
paramMenu.add(0, 1, 0, "Exit SMSmirror");
return true;
}
public boolean onMenuItemSelected(int paramInt, MenuItem paramMenuItem)
{
switch (paramMenuItem.getItemId())
{
default:
return super.onMenuItemSelected(paramInt, paramMenuItem);
case 0:
startActivityForResult(new Intent("android.intent.action.PICK", Contacts.People.CONTENT_URI), 5);
return true;
case 1:
}
Toast.makeText(this, "Goodbye!\nHave a great day! :D", 0).show();
System.exit(0);
return true;
}
public class MyCount extends CountDownTimer
{
DynamicMsg DM;
int maxNum;
String msg;
String num;
public MyCount(SMSmirror smSmirror, long arg2, long arg4, String paramString2, String paramInt, int arg8)
{
super(arg4, arg4);
this.num = paramString2;
this.msg = paramInt;
int i;
this.maxNum = i;
SMSmirror.this.sendBtn.setText("Sending...");
this.DM = new DynamicMsg(SMSmirror.this.getApplicationContext(), this.msg);
}
public void onFinish()
{
SMSmirror.this.sendSMS(this.num, this.DM.produceString());
ProgressBar localProgressBar = SMSmirror.this.pBar;
SMSmirror.this.Count = 0;
localProgressBar.setProgress(0);
Toast.makeText(SMSmirror.this.getBaseContext(), "Finished!", 0).show();
SMSmirror.this.sendBtn.setText("Send SMS");
SMSmirror.this.sending = false;
}
public void onTick(long paramLong)
{
if (SMSmirror.this.sending)
{
SMSmirror.this.sendSMS(this.num, this.DM.produceString());
ProgressBar localProgressBar2 = SMSmirror.this.pBar;
SMSmirror localSMSmirror = SMSmirror.this;
int i = 1 + localSMSmirror.Count;
localSMSmirror.Count = i;
localProgressBar2.setProgress(i);
SMSmirror.this.sendBtn.setText("Sending... (" + SMSmirror.this.Count + "/" + this.maxNum + ")");
return;
}
ProgressBar localProgressBar1 = SMSmirror.this.pBar;
SMSmirror.this.Count = 0;
localProgressBar1.setProgress(0);
SMSmirror.this.sendBtn.setText("Send SMS");
cancel();
}
}
Voici ma classe dynamicMsg
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
public class DynamicMsg
{
Context context;
int count;
String inputOrigin;
private Object str2;
private String str1;
public DynamicMsg(Context paramContext, String paramString)
{
this.context = paramContext;
this.inputOrigin = paramString;
this.count = 0;
}
private void _reportError(Exception paramException)
{
Toast.makeText(this.context, "Sorry ;( support Email sent\n" + paramException, 1).show();
Log.e("SMSBomber-DynamicMessage", paramException.toString());
new EmailReport(this.context, "SMSBomber", paramException).sendReport();
}
public String produceString()
{
Object localObject = "";
this.count = (1 + this.count);
int i = this.inputOrigin.split("%;%").length;
int j = 0;
int i1;
if (i > 0)
{
i1 = this.count;
if (i1 > i);
}
int k;
for (String str1 = this.inputOrigin.split("%;%")[(i1 - 1)]; ; str1 = this.inputOrigin)
{
k = 0;
if (k != str1.length() - 2)
break label120;
return localObject + str1.substring(j, str1.length());
i1 -= i;
break;
}
label120: String str2 = str1.substring(k, k + 3);
if (str2.equals("%#%"));
while (true)
{
try
{
String str8 = localObject + str1.substring(j, k);
localObject = str8;
localObject = localObject + this.count;
j = k + 3;
k++;
}
catch (Exception localException5)
{
try
{
String str7 = localObject + str1.substring(j - 1, k);
localObject = str7;
}
catch (Exception localException6)
{
_reportError(localException6);
}
continue;
}
if (str2.equals("%^%"))
{
int n = this.count;
char c2;
if (n <= 26)
c2 = (char)(n + 64);
try
{
String str6 = localObject + str1.substring(j, k);
localObject = str6;
localObject = localObject + c2;
j = k + 3;
continue;
n -= 26;
}
catch (Exception localException3)
{
while (true)
try
{
String str5 = localObject + str1.substring(j - 1, k);
localObject = str5;
}
catch (Exception localException4)
{
_reportError(localException4);
}
}
}
if (!str2.equals("%@%"))
continue;
int m = this.count;
char c1;
if (m <= 26)
c1 = (char)(m + 96);
try
{
String str4 = localObject + str1.substring(j, k);
localObject = str4;
localObject = localObject + c1;
j = k + 3;
continue;
m -= 26;
}
catch (Exception localException1)
{
while (true)
try
{
String str3 = localObject + str1.substring(j - 1, k);
localObject = str3;
}
catch (Exception localException2)
{
_reportError(localException2);
}
}
}
}
}
Mes 2 autre classe ne pose pas de problème particulier...
Merci de bien vouloir m'aider a résoudre mes erreur ou de me proposer une équivalence
Cordialement
Lsantoine37
Demande d'aide pour correction de codes
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.