1

Estoy aprendiendo a programar en android y me sale un error:

the error in the debbuger:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.android.octa.appprueba3, PID: 4131 Theme: themes:{} android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.DIAL dat=999999999 } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1514) at android.app.Activity.startActivityForResult(Activity.java:3930) at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79) at android.app.Activity.startActivityForResult(Activity.java:3890) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859) at android.app.Activity.startActivity(Activity.java:4213) at android.app.Activity.startActivity(Activity.java:4181) at com.android.octa.appprueba3.SecondActivity$1.onClick(SecondActivity.java:39) at android.view.View.performClick(View.java:5204) at android.view.View$PerformClick.run(View.java:21158) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5461) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

my manifest:

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.CALL_PHONE" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.APP_CONTACTS" />
        </intent-filter>
    </activity>
    <activity android:name=".SecondActivity"></activity>
</application>

my code, this is the mainAtivity:

   package com.android.octa.appprueba3;

  import android.content.Intent;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.Button;

 public class MainActivity extends AppCompatActivity {

     private Button bt;


     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

   bt = (Button) findViewById(R.id.buttonNext);
   bt.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {

       Intent intent1 = new Intent(MainActivity.this, SecondActivity.class);
        startActivity(intent1);

       }
   });

    }
}

the secondActivity:

package com.android.octa.appprueba3;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;


public class SecondActivity extends AppCompatActivity {

    private EditText editPhoneText;
    private ImageButton imageCallButton;
    private final int PHONE_CALL_CODE = 100;


    @Override
      protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_second);

        editPhoneText = (EditText) findViewById(R.id.editTextPhone);
      imageCallButton = (ImageButton) findViewById(R.id.imageCallButton1);



    imageCallButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
                Intent i = new Intent(Intent.ACTION_DIAL,  Uri.parse("999999999"));
                startActivity(i);
           }
       });

   }
}

1 respuesta 1

1

El error indica que no existe un intent para manipular correctamente la información:

No Activity found to handle Intent { act=android.intent.action.DIAL

veo que tienes definido el permiso:

<uses-permission android:name="android.permission.CALL_PHONE" />

Pero revisando el código estas definiendo el Intent incorrectamente:

 Intent i = new Intent(Intent.ACTION_DIAL,  Uri.parse("999999999"));

debe ser:

 Intent i = new Intent(Intent.ACTION_DIAL,  Uri.parse("tel:999999999"));

Debes agregar el protocolo tel:

Uri.parse("tel:" + numerotelefonico)

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.