[英]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.