查看intent.resolveActivity != null 但启动 Intent 会引发 ActivityNotFound 异常,我在打开浏览器或具有深度链接的应用程序时写道:
private fun openUrl(url: String) {
val intent = Intent().apply {
action = Intent.ACTION_VIEW
data = Uri.parse(url)
// setDataAndType(Uri.parse(url), "text/html")
// component = ComponentName("com.android.browser", "com.android.browser.BrowserActivity")
// flags = Intent.FLAG_ACTIVITY_CLEAR_TOP + Intent.FLAG_GRANT_READ_URI_PERMISSION
}
val activityInfo = intent.resolveActivityInfo(packageManager, intent.flags)
if (activityInfo?.exported == true) {
startActivity(intent)
} else {
Toast.makeText(
this,
"No application can handle the link",
Toast.LENGTH_SHORT
).show()
}
}
Run Code Online (Sandbox Code Playgroud)
它不起作用。在 API 30 模拟器中找不到浏览器,而一个常见的解决方案有效:
private fun openUrl(url: String) {
val intent …Run Code Online (Sandbox Code Playgroud) android android-manifest android-intent activitynotfoundexception android-11
我的第 3 方应用程序可以让最终用户从我们的服务器下载更新的 APK,然后该应用程序将在下载完成后调用该 APK 上的安装包管理器。同样的方法适用于所有版本的 Android 操作系统,但现在它会在 Android 10 (api 29) 上崩溃。我还没有看到任何人有类似的问题,任何帮助将不胜感激!
这是我用来从我的应用程序中调用 APK 文件的内容:
Intent intent = new Intent(Intent.ACTION_VIEW);
final File apkFile = new File(Files.getApkFileName());
Log.v("dt.update", "Start update from " + apkFile.getAbsolutePath());
intent.setDataAndType(Uri.fromFile(apkFile), application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
这是每次返回的堆栈跟踪,仅在 Android 10 / API29 上:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.MyAppHere, PID: 11107
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///storage/emulated/0/Download/updatedapp.apk typ=application/vnd.android.package-archive flg=0x10000000 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2051)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1709)
at android.app.Activity.startActivityForResult(Activity.java:5192)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:5150)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
at android.app.Activity.startActivity(Activity.java:5521)
at …Run Code Online (Sandbox Code Playgroud) 我ActivityNotFoundException在执行Intent.ACTION_CALL操作时得到.我找到了许多链接,但所有这些都无法解决我的问题.
它有时给我一些例外
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=tel:xxx-xxx-xxxx pkg=com.android.phone (has extras) }
Run Code Online (Sandbox Code Playgroud)
我在我的项目中使用了以下代码
String contact_number="123456789";
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + contact_number));
startActivity(callIntent);
Run Code Online (Sandbox Code Playgroud) 我目前有一个带有一些HTML电话号码和网址的TextView.
我注意到我们可以使用setMovementMethod使这些链接可以点击:
tv.setText("Phone number is: +32485123456 and url is http://www.blabla.com");
tv.setMovementMethod(LinkMovementMethod.getInstance());
Run Code Online (Sandbox Code Playgroud)
这非常有效,但在某些设备上,它会因ActivityNotFoundException而崩溃,这是非常难以理解的.(见下面的代码)
这些问题出现在我的开发者控制台中,我无法重现它们.
我面临的一个大问题是我无法在我的活动中尝试/捕获代码,因为点击是由LinkMovementMethod处理的
关于如何避免此类错误的任何想法?
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=www.vlaamsbrabant.be/zoutleeuw (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
at android.app.Activity.startActivityForResult(Activity.java:2817)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
at android.app.Activity.startActivity(Activity.java:2923)
at android.text.style.URLSpan.onClick(URLSpan.java:62)
at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:216)
at android.widget.TextView.onTouchEvent(TextView.java:6788)
at android.view.View.dispatchTouchEvent(View.java:3766)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1896)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1159)
at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1880)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1811)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at …Run Code Online (Sandbox Code Playgroud) android textview linkmovementmethod activitynotfoundexception
我正在尝试获得使用此权限访问应用使用情况数据的权限。仅针对棒棒糖完成此操作,并且当我以此意图开始活动(android.settings.USAGE_ACCESS_SETTINGS)时,应用程序崩溃(下面的stacktrace)
观察到另一个开发人员在这里的 LG G3手机线程中注意到了这个问题。从用户日志中,我主要看到这发生在LG G3和三星S5上。
启动LG和Samsung S3手机的窗口以获取应用使用数据的正确意图是什么?
有人拥有这些手机中的任何一部,并且可以建议该“使用使用情况数据的应用”权限选项是否存在
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.USAGE_ACCESS_SETTINGS }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1801)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1499)
at android.app.Activity.startActivityForResult(Activity.java:3913)
at android.app.Activity.startActivityForResult(Activity.java:3860)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivi ty.java:849)
at android.support.v4.app.Fragment.startActivity(Fragment.java:880)
at com.mavdev.focusoutfacebook.fragments.addablock.apps.Fragment_appsselect_addbloc k$2.onClick(Fragment_appsselect_addblock.java:182)
at android.view.View.performClick(View.java:5162)
at android.view.View$PerformClick.run(View.java:20873)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Run Code Online (Sandbox Code Playgroud)
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hidden"
android:installLocation="internalOnly"
android:versionCode="50"
android:versionName="2.0.5" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission …Run Code Online (Sandbox Code Playgroud) android usage-statistics activitynotfoundexception android-5.0-lollipop
我正在开发一个项目,我需要在设备屏幕上渲染pdf.
为此,我正在使用mupdf库.
我把它包含在我的项目中.
现在从图书馆项目,我需要通过意图使用MuPDFActivity.class来显示pdf.
但我得到的活动没有例外.
我试过在我的清单中包含库的活动.
<activity
android:name="com.example.xrgpc.mupdf.MuPDFActivity"
android:label="@string/app_name">
</activity>
Run Code Online (Sandbox Code Playgroud)
但我得到同样的错误.有人会指导我做错了什么.
android android-manifest activitynotfoundexception android-studio
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fitnesscircle.snapo">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
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" />
</intent-filter>
</activity>
</application>
<activity
android:name="com.afollestad.materialcamera.CaptureActivity"
android:label="@string/app_name"
android:theme="@style/MaterialCamera.CaptureActivity" />
<activity
android:name="com.afollestad.materialcamera.CaptureActivity2"
android:theme="@style/MaterialCamera.CaptureActivity" />
<activity
android:name="com.afollestad.materialcamera.MaterialCamera"
/>
Run Code Online (Sandbox Code Playgroud)
即使我注册它仍然说找不到明确的活动类。我是 Android 编码新手。我需要改变什么所以我摆脱了这个 ActivityNotFoundException
无法找到显式活动类 {com.fitnesscircle.snapo/com.afollestad.materialcamera.CaptureActivity};您是否在 AndroidManifest.xml 中声明了此活动
请帮忙
我正在尝试使用软件包名称打开某些应用程序,为此我使用了以下代码:
public void openAppHavingPackageName(String packageName, String appName) {
try {
Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(packageName);
startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.e(TAG, e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试打开手机中安装的应用程序时,它工作正常,但是当我尝试打开手机中没有的应用程序时,应用程序崩溃并出现以下错误:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
在线上
startActivity(intent);
如您所见,我在try/catch那里有一个块,那么为什么没有捕获异常,而是运行代码导致崩溃?
android try-catch nullpointerexception android-package-managers activitynotfoundexception
有人遇到过这个问题吗?当我在 上构建应用程序时targetSdk 33,应用程序不会打开ActivityNotFoundException在我的pixel 6 android 13.
构建设置导致崩溃:
compileSdk = 33
targetSdk = 33
minSdk = 23
buildTools = "33.0.1"
Run Code Online (Sandbox Code Playgroud)
日志猫崩溃:
Activity not found to handle Intent action [CONTEXT service_id=77 ]
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.somecompany.app/com.somecompany.app.MainActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2197)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1839)
at android.app.Activity.startActivityForResult(Activity.java:5471)
at hcl.platform_startActivityForResult(:com.google.android.gms@230313044@23.03.13 (190400-503260631):2)
at hck.startActivityForResult(:com.google.android.gms@230313044@23.03.13 (190400-503260631):2)
at com.google.android.chimera.android.Activity.startActivityForResult(:com.google.android.gms@230313044@23.03.13 (190400-503260631):2)
at hgw.startActivityForResult(:com.google.android.gms@230313044@23.03.13 (190400-503260631):2)
at …Run Code Online (Sandbox Code Playgroud) android firebase activitynotfoundexception firebase-dynamic-links
所以我的应用程序有一个例外如下:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://google.com (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
at android.app.Activity.startActivityForResult(Activity.java:3248)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
at android.app.Activity.startActivity(Activity.java:3359)
at android.text.style.URLSpan.onClick(URLSpan.java:62)
at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:212)
at android.widget.TextView.onTouchEvent(TextView.java:8704)
at android.view.View.dispatchTouchEvent(View.java:5556)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1940)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1390)
at android.app.Activity.dispatchTouchEvent(Activity.java:2414)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1888)
at android.view.View.dispatchPointerEvent(View.java:5736)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3017)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2582)
at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:887)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2591)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4697) …Run Code Online (Sandbox Code Playgroud)