在Chrome(Canary)上测试Android应用时,我偶然发现了这个问题。
我正在使用
尝试ACTION_SEND内容(json文本文件)String tempFile = <path_to_file>;
Uri contentUri = FileProvider.getUriForFile(this, "<app.namespace>", tempFile);
baseIntent.setAction(Intent.ACTION_SEND);
baseIntent.setType("application/json");
baseIntent.putExtra(Intent.EXTRA_SUBJECT, contentUri.getLastPathSegment());
baseIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
baseIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Intent chooser = Intent.createChooser(baseIntent, "Hello!");
startActivityForResult(chooser, 1234);
在实际设备中,这项工作效果很好,但作为Chrome应用,它会在选择&#34; Arc&#34;之后导致崩溃。来自意图选择器。
我无法让日志工作。
在Chrome日志中,我找到了这个堆栈跟踪:
[6128:5632:0806/153905:INFO:CONSOLE(38)] "stack_trace: java.lang.RuntimeException
at android.os.Process$1.run(Process.java:536)
Caused by java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.os.Process$1.run(Process.java:529)
Caused by java.lang.RuntimeException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2385)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2447)
at android.app.ActivityThread.access$800(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1320)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5510)
...3 more
Caused by android.database.CursorIndexOutOfBoundsException
at android.database.MatrixCursor.get(MatrixCursor.java:66)
at android.database.MatrixCursor.getString(MatrixCursor.java:254)
at android.database.CursorWrapper.getString(CursorWrapper.java:114)
at org.chromium.arc.helper.SendIntentHandler.getSuggestNameFromUri(SendIntentHandler.java:540)
at org.chromium.arc.helper.SendIntentHandler.getSuggestName(SendIntentHandler.java:588)
at org.chromium.arc.helper.SendIntentHandler.saveToExternalFile(SendIntentHandler.java:615)
at org.chromium.arc.helper.SendIntentHandler.run(SendIntentHandler.java:638)
at org.chromium.arc.helper.ArcActivity.onCreate(ArcActivity.java:56)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
...9 more
", source: chrome-extension://goanhijinjeebfniolhakmhgodjiflod/_modules/mfaihdlpglflfgpfjcifdjdjcckigekc/gen_main.min.js (38)
但它与我的代码没有直接关系。
我做错了什么?