代码不能在Pixel4的Android 13中运行,但它可以在其他手机上运行。
Intent share_intent = new Intent();
share_intent.setAction(Intent.ACTION_SEND);
share_intent.setType("video/*");
share_intent.putExtra(Intent.EXTRA_STREAM,fileUri);
final PackageManager pm = m_activity.getPackageManager();
List<ResolveInfo> resInfo = pm.queryIntentActivities(share_intent, 0);
List<LabeledIntent> intentList = new ArrayList<>();
for (int i = 0; i < resInfo.size(); i++) {
ResolveInfo ri = resInfo.get(i);
String packageName = ri.activityInfo.packageName;
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("video/*");
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
intent.putExtra(Intent.EXTRA_TITLE, "ttt00");
CharSequence title = "123";
intentList.add(new LabeledIntent(intent, packageName, title, ri.getIconResource()));
}
Intent openInChooser = Intent.createChooser(intentList.remove(0), "Share");
openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentList.toArray(new Parcelable[intentList.size()]));
m_activity.startActivityForResult(openInChooser,GameActivity.ActivityRequestCode.SHARE_VIDEO);
它将抛出异常
2022-05-26 20:22:35.144 1685-3668/? E/PackageManager: Package Manager Unexpected Exception
android.os.BadParcelableException: Parcel data not fully consumed, unread size: 40
at android.os.Parcel.enforceNoDataAvail(Parcel.java:929)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2216)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:7086)
at android.os.Binder.execTransactInternal(Binder.java:1280)
at android.os.Binder.execTransact(Binder.java:1244)
2022-05-26 20:22:35.146 29790-29790/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: android:ui, PID: 29790
java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.android.internal.app.ChooserActivity}: android.os.BadParcelableException: Parcel data not fully consumed, unread size: 40
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3816)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:99)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2299)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7844)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
PS:
什么是It looks like your post is mostly code; please add some more details.
,但我没有细节要说,这是所有,但为什么我不能张贴...
对于例外,你是否有同样的追求?谁能帮帮我?
1条答案
按热度按时间cyvaqqii1#
使用@Parcelize可以从地块中读取数据并将数据写入地块。如果不这样做,您需要非常小心写入和读取数据的顺序。它们应该完全一样。否则,数据将被覆盖,或者在最坏的情况下被损坏。@Parcelize在引擎盖下为您做这项工作。https://developer.android.com/kotlin/parcelize