Android - Error: E/AndroidRuntime: FATAL EXCEPTION: main, java.lang.IllegalStateException: Could not execute m

   
Vista:

Error: E/AndroidRuntime: FATAL EXCEPTION: main, java.lang.IllegalStateException: Could not execute m

Publicado por Juan (1 intervención) el 28/02/2018 00:55:40
Tengo el siguiente codigo que sirve para mandar un mensaje, pero al momento de enviar el mensaje se me cierra la aplicación:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
public class MainActivity extends AppCompatActivity {
    private EditText txtTexto1;
    private EditText txtTexto2;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS},1);
 
 
        txtTexto1 = (EditText)findViewById(R.id.txttexto1);
        txtTexto2 = (EditText) findViewById(R.id.txttexto2);
 
 
    }
 
 
    public void btnEnviar1OnClick(View view){
        String strPhone = "4773849166";
        String strMessage = txtTexto1.getText().toString();
 
        Intent sendIntent = new Intent(Intent.ACTION_VIEW);
        sendIntent.setType("vnd.android-dir/mms");
        sendIntent.putExtra("address", strPhone);
        sendIntent.putExtra("sms_body", strMessage);
        startActivity(sendIntent);
    }
 
    public void btnEnviar2OnClick(View view){
        String strPhone = "4773849166";
        String strMessage = txtTexto2.getText().toString();
 
        try {
            SmsManager sms = SmsManager.getDefault();
 
            if (strMessage.length() > 160) {
                ArrayList messageParts  = sms.divideMessage(strMessage);
                sms.sendMultipartTextMessage(strPhone, null, messageParts, null, null);
                Toast.makeText(this, "Mensaje Enviado", Toast.LENGTH_SHORT).show();
 
 
            } else {
                sms.sendTextMessage(strPhone, null, strMessage, null, null);
                Toast.makeText(this, "Mensaje Enviado", Toast.LENGTH_SHORT).show();
            }
 
        }
        catch (Exception e){
            Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
 
        }
    }
 
}


Me manda el siguiente error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
E/AndroidRuntime: FATAL EXCEPTION: main
	Process: com.android.enviarsms2, PID: 5430
	java.lang.IllegalStateException: Could not execute method for android:onClick
		at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
		at android.view.View.performClick(View.java:5637)
		at android.view.View.onKeyUp(View.java:10661)
		at android.widget.TextView.onKeyUp(TextView.java:6436)
		at android.view.KeyEvent.dispatch(KeyEvent.java:2712)
		at android.view.View.dispatchKeyEvent(View.java:9960)
		at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
		at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
		at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
		at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
		at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
		at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
		at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:405)
		at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1798)
		at android.app.Activity.dispatchKeyEvent(Activity.java:3021)
		at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:534)
		at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58)
		at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:316)
		at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:319)
		at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4331)
		at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4302)
		at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
		at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
		at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
		at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3999)
		at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3880)
		at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4056)
		at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
		at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
		at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
		at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3880)
		at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
		at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
		at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
		at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4032)
		at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4193)
		at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2400)
		at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1964)
		at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1955)
		at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2377)
		at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
		at android.os.MessageQueue.nativePollOnce(Native Method)
		at android.os.MessageQueue.next(MessageQueue.java:323)
		at android.os.Looper.loop(Looper.java:136)
		at android.app.ActivityThread.main(ActivityThread.java:6119)
		at java.lang.reflect.Method.invoke(Native Method)
		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
	Caused by: java.lang.reflect.InvocationTargetException
		at java.lang.reflect.Method.invoke(Native Method)
		at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
E/AndroidRuntime: 	... 47 more
	Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=vnd.android-dir/mms (has extras) }
		at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1809)
		at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
		at android.app.Activity.startActivityForResult(Activity.java:4225)
		at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
		at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)
		at android.app.Activity.startActivityForResult(Activity.java:4183)
		at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:720)
		at android.app.Activity.startActivity(Activity.java:4522)
		at android.app.Activity.startActivity(Activity.java:4490)
		at com.itl.enviarsms2.MainActivity.btnEnviar1OnClick(MainActivity.java:44)

Eh asignado los permisos para poder enviar los mensajes pero me manda el erro, y aun no se como resolverlo.

Saludos.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Error: E/AndroidRuntime: FATAL EXCEPTION: main, java.lang.IllegalStateException: Could not execute m

Publicado por Juan (15 intervenciones) el 28/02/2018 22:15:10
Buenas tocayo

Una cosa, tienes declarados los métodos getText() en la clase???? Si no es así, el error puede ser ése, ya que si no tienes los métodos declarados, no te da error de sintaxis, pero sí al ejecutar porque éstos no existen.

Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar