Android Action_DIAL error "No Activity found to handle Intent {act = android.intent.action.DIAL"

1

When making a call using Action_DIAL I get the following error:

09-28 16:47:31.610 2079-2079/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 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:3511)
                                                     at android.view.View$PerformClick.run(View.java:14105)
                                                     at android.os.Handler.handleCallback(Handler.java:605)
                                                     at android.os.Handler.dispatchMessage(Handler.java:92)
                                                     at android.os.Looper.loop(Looper.java:137)
                                                     at android.app.ActivityThread.main(ActivityThread.java:4424)
                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                     at java.lang.reflect.Method.invoke(Method.java:511)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
                                                     at dalvik.system.NativeStart.main(Native Method)
                                                  Caused by: java.lang.reflect.InvocationTargetException
                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                     at java.lang.reflect.Method.invoke(Method.java:511)
                                                     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                                                     at android.view.View.performClick(View.java:3511) 
                                                     at android.view.View$PerformClick.run(View.java:14105) 
                                                     at android.os.Handler.handleCallback(Handler.java:605) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:92) 
                                                     at android.os.Looper.loop(Looper.java:137) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:4424) 
                                                     at java.lang.reflect.Method.invokeNative(Native Method) 
                                                     at java.lang.reflect.Method.invoke(Method.java:511) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
                                                     at dalvik.system.NativeStart.main(Native Method) 
                                                  Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.DIAL [email protected] }
                                                     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
                                                     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
                                                     at android.app.Activity.startActivityForResult(Activity.java:3190)
                                                     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:708)
                                                     at android.app.Activity.startActivity(Activity.java:3297)
                                                     at com.example.eac1.EAC1.Trucar(EAC1.java:154)
                                                     at java.lang.reflect.Method.invokeNative(Native Method) 
                                                     at java.lang.reflect.Method.invoke(Method.java:511) 
                                                     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
                                                     at android.view.View.performClick(View.java:3511) 
                                                     at android.view.View$PerformClick.run(View.java:14105) 
                                                     at android.os.Handler.handleCallback(Handler.java:605) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:92) 
                                                     at android.os.Looper.loop(Looper.java:137) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:4424) 
                                                     at java.lang.reflect.Method.invokeNative(Native Method) 
                                                     at java.lang.reflect.Method.invoke(Method.java:511) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
                                                     at dalvik.system.NativeStart.main(Native Method) 

The part of the program is this:

public void Trucar(View vista) {
        // primero pasamos el texto a String para poder analizarlo.
        String textoTelf = telf.getText().toString();
        if (textoTelf == "Valor no definit" || textoTelf.equalsIgnoreCase("Valor no definit") || textoTelf.isEmpty()) { // Si el texto esta vacío..
            Toast toast1 = Toast.makeText(getApplicationContext(), "El camp ''Telefon'' està buït!", Toast.LENGTH_LONG);
            toast1.show(); // en aquest cas mostrare sempre que hi estigui el valor no definit i empty podría fer apart
            // verificacions per veure si conté 9 números etc.. Si hem dona temps pulire aquestes coses.

       } else { // Funcion llamar.

            Intent intent = new Intent(Intent.ACTION_DIAL);
            intent.setData(Uri.parse(String.valueOf(telf)));
            startActivity(intent);
                }
            }

Basically I want to call telf but it does not come out! :( I do not know what I'm doing wrong ... The idea is that the text gets it from an EditText.

    
asked by Montse Mkd 28.09.2017 в 18:52
source

1 answer

2

The generated error that shows your LogCat is:

  

Caused by: android.content.ActivityNotFoundException: No Activity   found to handle Intent {act = android.intent.action.DIAL}

This error is due to incorrect phone value, empty string or null value, for this reason it does not recognize the type of Intent .

It is important to ensure that in addition to having a correct phone number, this has at the beginning the scheme to identify what is a call , in case you must add to the beginning of the phone:

tel:+

for example a number (214) 3371154 would have to be sent in this way:

tel:+2143371154

This will work correctly with your code:

 Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse(String.valueOf("tel:+2143371154")));
        startActivity(intent);
    
answered by 28.09.2017 / 19:37
source