为什么日志收集器市场的链接不起作用?

时间:2013-01-10 20:42:47

标签: android android-emulator

我尝试将LogCollector包含到我的应用程序中并使用此站点的集成示例

http://code.google.com/p/android-log-collector/source/browse/trunk/android-log-collector-usage/src/com/xtralogic/android/logcollector/usage/Main.java

但是当我尝试在我的应用程序中使用它时,它正确显示它未安装

http://pbrd.co/VVD1Bx

但是在尝试打开市场时它会崩溃,这是日志输出

    01-10 20:38:04.309: E/AndroidRuntime(3265): FATAL EXCEPTION: main
    01-10 20:38:04.309: E/AndroidRuntime(3265): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://search?q=pname:com.xtralogic.android.logcollector flg=0x10000000 }
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at android.app.Activity.startActivityForResult(Activity.java:2817)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at android.app.Activity.startActivity(Activity.java:2923)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at de.srs.android.pdixuploader.activies.SettingsActivity$1.onClick(SettingsActivity.java:102)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at android.os.Handler.dispatchMessage(Handler.java:99)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at android.os.Looper.loop(Looper.java:123)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at java.lang.reflect.Method.invokeNative(Native Method)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at java.lang.reflect.Method.invoke(Method.java:521)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    01-10 20:38:04.309: E/AndroidRuntime(3265):     at dalvik.system.NativeStart.main(Native Method)

这可能是什么原因?我在模拟器上测试它。

由于

1 个答案:

答案 0 :(得分:3)

这是因为它试图在Google Play上打开应用程序页面,并且模拟器没有安装Google Play。

因此,没有app来处理market:// URI方案,导致ActivityNotFoundException

您的链接可在安装了Google Play的设备上查找。请记住,从Android 4.2开始,LogCollector不再能够访问其他应用程序的日志(或任何其他日志应用程序,除非它在root设备上具有root权限)。

您可以使用以下方法检查设备是否已嵌入Google Play:

public boolean hasGooglePlayInstalled() {
    Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=dummy"));
    PackageManager manager = mContext.getPackageManager();
    List<ResolveInfo> list = manager.queryIntentActivities(market, 0);

    if (list != null && list.size() > 0) {
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).activityInfo.packageName.startsWith("com.android.vending") == true) {
                return true;
            }
        }
     }
    return false;
}