简体   繁体   English

android.content.ActivityNotFoundException:未找到用于处理Intent的活动

[英]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) ....................................................................... 请帮助,当我运行该应用程序时,该应用程序会启动致命错误,我正在学习我只是通过调用创建了一个instat但未运行,(抱歉我的英语)...... ................................................... ......

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. 要直接在您的应用中进行调用,意图应为Intent.ACTION_CALL ,它需要您声明的权限。

Hope this will help. 希望这会有所帮助。

There is no activity on your device that handles ACTION_DIAL for a Tel: scheme. 您的设备上没有为Tel:方案处理ACTION_DIAL活动。 Try: 尝试:

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

Case and whitespace are important when assembling a Uri . 组装Uri时,大小写和空白很重要。

Also note that even my revised Intent will not work on all devices, such as on an Android tablet that lacks a dialer. 另请注意,即使是我修订的Intent也无法在所有设备上使用,例如在没有拨号器的Android平板电脑上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android错误:“ android.content.ActivityNotFoundException:未找到用于处理Intent的活动” - Android error : “android.content.ActivityNotFoundException: No Activity found to handle Intent” 致命异常:android.content.ActivityNotFoundException:未找到处理 Intent 的活动 - Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent android.content.ActivityNotFoundException:未找到任何处理Intent的活动{act = android.intent.action.GET_CONTENT - android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT android.content.ActivityNotFoundException:没有找到处理意图的活动{act=android.intent.action.VIEW dat=PendingIntent{} - android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=PendingIntent{ } android.content.ActivityNotFoundException: 没有找到处理意图的活动 { act=activity2.application1 (有额外的) } - android.content.ActivityNotFoundException: No Activity found to handle Intent { act=activity2.application1 (has extras) } android.content.ActivityNotFoundException:未找到任何处理Intent的活动{act = login_filter(有其他功能)} - android.content.ActivityNotFoundException: No Activity found to handle Intent { act=login_filter (has extras) } android.content.ActivityNotFoundException:将url传递给intent - android.content.ActivityNotFoundException: passing url to the intent android.content.ActivityNotFoundException,无法开始活动 - android.content.ActivityNotFoundException ,unable to start activity android.content.ActivityNotFoundException:无法在Android中找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class in Android android.content.ActivityNotFoundException:无法找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM