【问题标题】:ActivityNotFoundException: No Activity found to handle Intent sospicious behaviourActivityNotFoundException:未找到处理 Intent 可疑行为的活动
【发布时间】:2016-05-16 00:18:47
【问题描述】:

我有一个正在生产的应用,在过去的 24 小时内,我收到了来自单个用户的大约 50 次崩溃(每小时 3-4 次)。

Fabric 将设备类型标记为“sdk”,操作系统版本始终为 4.1.1。

这是堆栈跟踪:

Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms&pcampaignid=gcore_8487000--- flg=0x80000 pkg=com.android.vending }
   at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
   at android.app.Activity.startActivityForResult(Activity.java:3351)
   at android.app.Activity.startActivityForResult(Activity.java:3312)
   at android.support.v4.app.FragmentActivity.startActivityForResult(SourceFile:843)
   at android.app.Activity.startActivity(Activity.java:3522)
   at android.app.Activity.startActivity(Activity.java:3490)
   at com.google.android.gms.dynamic.zza$5.onClick(Unknown Source)
   at android.view.View.performClick(View.java:4084)
   at android.view.View$PerformClick.run(View.java:16966)
   at android.os.Handler.handleCallback(Handler.java:615)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4745)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
   at dalvik.system.NativeStart.main(NativeStart.java)

我的包名没有任何迹象,看起来该应用正在尝试打开我无法控制的内部意图。

这可能是没有 Google Play 商店的用户/机器人吗?

【问题讨论】:

    标签: android android-intent android-activity twitter-fabric


    【解决方案1】:

    好的,所以发生的情况是您的应用崩溃的设备不包含任何应用来处理从您的应用发送的隐式意图。

    这意味着,在您的代码中的某处,您可能已经发送了一个带有 View 操作的隐式意图。现在,当它在不包含任何 Activity 来解析视图意图的设备上运行时,它会崩溃。在启动 Activity 之前,您应该始终检查从您的代码发送的意图是否可以被设备上的其他应用程序处理。比如:

    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
    sendIntent.setType("text/plain");
    
    // Verify that the intent will resolve to an activity
    if (sendIntent.resolveActivity(getPackageManager()) != null) {
        startActivity(sendIntent);
    }
    

    正如您在上面的代码中看到的,resolveActivity() 方法在启动活动之前被调用。如果 android 没有找到任何能够处理您的意图的应用程序,它会返回 null,然后也许您可以设置一个 else 条件并优雅地处理这种情况。我从日志中收集到的信息是,您可能已经发送了一个带有 ACTION_VIEW 的意图,以便在系统认为有能力的任何其他应用程序上查看您的应用程序中的某些项目。

    来源:https://developer.android.com/guide/components/intents-filters.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-29
      • 1970-01-01
      • 1970-01-01
      • 2015-03-08
      • 1970-01-01
      相关资源
      最近更新 更多