简体   繁体   中英

android.content.ActivityNotFoundException: No Activity found to handle Intent

please help , when i run the app, the app launch a Fatal Error im learning just i create a instat with a call but not run, (sorry for my english) .......................................................................

my manifest:

<?xml version="1.0" encoding="utf-8"?>
   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.octa.appprueba3">

        <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>

       </manifest>

my code:

 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) {
            implicito();
        }
    });
}

    public void implicito(){

        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("Tel: 9999999" ));
        startActivity(intent);

}
}

You may want to check whether your device can handle your intent by doing this:

PackageManager packageManager = getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
    startActivity(intent);
} else {
     Log.d(TAG, "Cannot handle this intent");
}

What's more, if you are placing a call like so, there is NO need to declare the permission in your manifest:

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

Because you are not directly calling someone within your app. You are actually transferring the "duty" to other apps which can handle your intent to call. This doesn't need a permission.

To directly make a call within your app, the intent should be Intent.ACTION_CALL , which needs the permission you declared.

Hope this will help.

There is no activity on your device that handles ACTION_DIAL for a Tel: scheme. Try:

Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:9999999" ));

Case and whitespace are important when assembling a Uri .

Also note that even my revised Intent will not work on all devices, such as on an Android tablet that lacks a dialer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM