尝试从可绘制资源共享图像时崩溃

时间:2020-04-08 15:49:52

标签: android android-intent android-drawable android-resources android-bitmap

我正在尝试实现共享机制,但是崩溃了(不幸的是,日志中什么也没有...)。我正在使用模拟器Pixel 2 API 27,但在真实设备LG G7上也崩溃了。

这是我正在使用的代码:

        val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.myDrawable)
        val file =  File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "test_${System.currentTimeMillis()}.jpg")
        val out = FileOutputStream(file)
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)
        out.close()
        val uri = Uri.fromFile(file)
        val shareIntent: Intent = Intent().apply {
            action = Intent.ACTION_SEND
            putExtra(Intent.EXTRA_STREAM, uri)
            type = "image/jpeg"
        }
        activity.startActivity(shareIntent)

当我调试时,调用后我只会崩溃:

activity.startActivity(shareIntent)

如何解决此问题并正确执行?

下面的Logcat,也许会帮助调查:

2020-04-08 17:58:50.339 2966-2966/? W/MainApplication: onReceive intent : Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) }
2020-04-08 17:58:50.340 2360-2360/? D/KeyguardUpdateMonitor: received broadcast android.intent.action.BATTERY_CHANGED
2020-04-08 17:58:50.340 2360-2360/? D/KeyguardUpdateMonitor: Intent.ACTION_BATTERY_CHANGED status : 5 ,plugged : 22 ,charging : false ,level : 100 ,temperature : 254, temperatureState : 0, EXTRA_CHARGING_CURRENT : 0 / EXTRA_HVDCP_TYPE : false
2020-04-08 17:58:50.340 2360-2360/? D/KeyguardUpdateMonitor: handleBatteryUpdate
2020-04-08 17:58:50.344 2844-2844/? D/TeleService: PhoneGlobalsEx: onReceive: android.intent.action.BATTERY_CHANGED
2020-04-08 17:58:50.344 2360-2584/? I/AbsQuickSettingsHandlerBase: Got action android.intent.action.BATTERY_CHANGED for battery
2020-04-08 17:58:50.345 1838-3966/? V/LocSvc_HIDL_Subscription_jni: battery_level_update
2020-04-08 17:58:50.345 1838-3966/? V/LocSvc_HIDL_Subscription_jni: [battery_level_update][896] [HC] =>> [HS]
2020-04-08 17:58:50.345 2360-2360/? I/LGPowerUI: onReceive = android.intent.action.BATTERY_CHANGED
2020-04-08 17:58:50.345 1374-1374/? V/LocSvc_HIDL_IzatSubscription: [batteryLevelUpdate][757] [HS] <<<<= [HC]
2020-04-08 17:58:50.346 2360-2360/? I/LGPowerUI: level = 100, plugType = 2, plugged = true, charging = false, temperature = 254, chargingCurrent = 0, factoryCableItem = 0, isFastCharging = false, batteryID = 1
2020-04-08 17:58:50.346 2360-2360/? I/LowBatteryModeManager: applyCmrMode() enabled: false batteryLevel: 100
2020-04-08 17:58:50.346 1838-3966/? V/LocSvc_HIDL_Subscription_jni: Exit Result 0

    --------- beginning of system
2020-04-08 17:58:50.346 1838-6745/? I/DisplayPowerControllerEx: requested BacklightDimming target[-1]
2020-04-08 17:58:50.346 2360-2360/? I/LowBatteryModeManager: setCmrMode(false)
2020-04-08 17:58:50.354 1838-2238/? D/WifiController: battery changed pluggedType: 2
2020-04-08 17:58:50.378 835-965/? W/HWComposer: Ignoring duplicate VSYNC event from HWC (t=24724858800000)
2020-04-08 17:58:50.397 835-965/? W/HWComposer: Ignoring duplicate VSYNC event from HWC (t=24724875507000)
2020-04-08 17:58:50.417 2117-2126/? E/nightwatch-watcher: Failed to read from logcat: Success
2020-04-08 17:58:50.824 809-4637/? D/sensors_hal_accel: handle_sns_std_sensor_event:89, accel_sample: ts=24725270340672 ns; value = [0.026188, 8.079635, 5.679935]
2020-04-08 17:58:50.916 1838-2309/? D/WifiWatchdogStateMachine: EVENT_CHECK_IMS_CALL_STATE received
2020-04-08 17:58:50.917 1838-2309/? D/WifiWatchdogStateMachine: OnlineWatchState handleRssiChange() imscallstate : 0
2020-04-08 17:58:50.922 1664-1664/? E/MSM-irqbalance: IRQ 82 not found in internal structure or should be ignored
2020-04-08 17:58:51.422 2117-2126/? E/nightwatch-watcher: Failed to read from logcat: Success
2020-04-08 17:58:51.735 809-4637/? D/sensors_hal_accel: handle_sns_std_sensor_event:89, accel_sample: ts=24726203678380 ns; value = [0.027787, 8.078243, 5.671582]
2020-04-08 17:58:51.762 1375-1375/? D/cnss-daemon: pfd[1].fd: 7 has data to process
2020-04-08 17:58:51.762 1375-1375/? D/cnss-daemon: cnss_gw_update_loop: received bytes: 76
2020-04-08 17:58:51.762 1375-1375/? D/cnss-daemon: cnss_gw_update_loop: nlmsg_type: 28
2020-04-08 17:58:51.762 1375-1375/? D/cnss-daemon: RTM_NEWNEIGH message received: 28
2020-04-08 17:58:51.762 1375-1375/? D/cnss-daemon: neighbor response rcvd for ipv4 neighbor
2020-04-08 17:58:51.762 1375-1375/? D/cnss-daemon: ndm_state: 4
2020-04-08 17:58:51.762 1375-1375/? D/cnss-daemon: Stale or unreachable neighbors,ndm state: 4
2020-04-08 17:58:51.809 1838-1849/? W/ActivityManager:   Force finishing activity com.test.activity.MyActivity
2020-04-08 17:58:51.821 1838-1870/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2020-04-08 17:58:51.821 3652-6878/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:951 android.content.ContextWrapper.sendBroadcast:431 com.lge.mlt.providers.LDBSmartCareTrigger.sendMsgSmartCare:33 com.lge.mlt.providers.LDBMainLogProvider.insert:273 android.content.ContentProvider$Transport.insert:268 
2020-04-08 17:58:51.821 1838-1870/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2020-04-08 17:58:51.823 1838-3632/? W/ActivityManager: Sending non-protected broadcast com.lge.mlt.action.smartcare.event from system 3652:com.lge.mlt/1000 pkg com.lge.mlt
2020-04-08 17:58:51.823 1838-1871/? D/PhoneWindow: windowLightStatusBar : false, disable View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
2020-04-08 17:58:51.825 2355-2517/? D/ViewRootImpl: onChangedNavigationGuardColor(), color: ffffffff
2020-04-08 17:58:51.828 2627-2627/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1461 android.content.ContextWrapper.startService:644 android.content.ContextWrapper.startService:644 com.lge.ia.intenttask.LIAIntentReceiver.sendIntent:95 com.lge.ia.intenttask.LIAIntentReceiver.onReceive:58 
2020-04-08 17:58:51.842 2355-2355/? D/DecorView: updateNavigationGuardColor navigationGuardColor=0xffffffff
2020-04-08 17:58:51.844 2627-5716/? I/LIA_SDK_V0.8.35_LogCore: LIA Log Open() - prefix : LIA_SDK_V0.8.35_
2020-04-08 17:58:51.846 2627-5716/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1461 android.content.ContextWrapper.startService:644 com.lge.ia.connection.ConnectionProxy.tryStartService:59 com.lge.ia.ConnectionProxyHandler.tryConnecting:179 com.lge.ia.LGIntelligentAgent.tryConnecting:209 
2020-04-08 17:58:51.847 835-965/? W/HWComposer: Ignoring duplicate VSYNC event from HWC (t=24726328331000)
2020-04-08 17:58:51.853 1838-1871/? D/InputDispatcher: Focus left window: Window{17c5a34 u0 com.test.activit.MyActivity}
2020-04-08 17:58:51.853 1838-1871/? D/InputDispatcher: Focus entered window: Window{5d9148c u0 Application Error: com.test.debug}
2020-04-08 17:58:51.854 1348-1464/? I/PowerRM: System FW:0 IC:0 SO:0 GT:0 CAPP:-1 APP:0
2020-04-08 17:58:51.854 1838-1871/? D/BezellessGripSuppressionFilter: getdisplaysize, x : 1440 y : 3120
2020-04-08 17:58:51.855 1348-1464/? E/PowerRM: found 42, mode set to 0
2020-04-08 17:58:51.855 1838-1871/? I/ActivityManager: Showing crash dialog for package com.test.debug u0
2020-04-08 17:58:51.855 1348-1464/? I/PowerRM: System FW:1 IC:0 SO:0 GT:0 CAPP:-1 APP:0
2020-04-08 17:58:51.855 2627-5716/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1541 android.content.ContextWrapper.bindService:678 com.lge.ia.connection.ConnectionProxy.tryBindService:80 com.lge.ia.ConnectionProxyHandler.tryConnecting:188 com.lge.ia.LGIntelligentAgent.tryConnecting:209 
2020-04-08 17:58:51.855 1348-1464/? E/PowerRM: found 42, mode set to 0
2020-04-08 17:58:51.855 1348-1464/? I/PowerRM: FIA lock1 locked
2020-04-08 17:58:51.873 1838-3881/? I/Adreno: QUALCOMM build                   : 819682a, Idd487cf99a
    Build Date                       : 09/05/18
    OpenGL ES Shader Compiler Version: EV031.23.00.04
    Local Branch                     : 
    Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.6.3.C2.08.00.00.435.090
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
2020-04-08 17:58:51.875 2360-2360/? I/NavigationThemeResource: notify navigation bar color(0x0)
2020-04-08 17:58:51.875 2360-2360/? I/NavigationThemeResource: NavigationKey Color is changed(BLACK -> WHITE_WITH_BORDER)
     BarMode=4, Theme=WHITE, LightBackground=false (Transparent)
    , Keyguard show=false, IME shown=false, Bar vertical=false, Panel expanded=false
2020-04-08 17:58:51.876 2355-2517/? D/ViewRootImpl: onChangedNavigationGuardColor(), color: ffffffff
2020-04-08 17:58:51.876 2355-2355/? D/DecorView: updateNavigationGuardColor navigationGuardColor=0xffffffff
2020-04-08 17:58:51.878 1838-3881/? I/Adreno: PFP: 0x016ee155, ME: 0x00000000
2020-04-08 17:58:51.878 2360-2360/? D/StatusBar: setSystemUiVisibility vis=8008 mask=ffffffff oldVal=a608 newVal=8008 diff=2600
2020-04-08 17:58:51.878 1838-3881/? I/Adreno: PFP: 0x016ee155, ME: 0x00000000
2020-04-08 17:58:51.888 1838-3881/? I/OpenGLRenderer: Initialized EGL, version 1.4
2020-04-08 17:58:51.888 1838-3881/? D/OpenGLRenderer: Swap behavior 2
2020-04-08 17:58:51.919 2360-2972/? I/SystemServicesProxy: RecentApps has 2 item(s).
2020-04-08 17:58:51.923 1838-3632/? V/LGSettingsProvider: call_put(secure:overview_last_stack_active_time=1586361483972)  calling package = com.android.systemui  callingUserId : 0
2020-04-08 17:58:51.925 2627-2627/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.stopService:1473 android.content.ContextWrapper.stopService:654 com.lge.ia.manager.remote.LIARemoteManager.onAllSessionFinished:89 com.lge.ia.manager.session.LocalSessionManager.onTaskSessionFinished:116 com.lge.ia.manager.session.TaskContext.onAppSessionFinished:121 
2020-04-08 17:58:51.929 2627-2627/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.stopService:1473 android.content.ContextWrapper.stopService:654 com.lge.ia.connection.ConnectionProxy.tryStopService:167 com.lge.ia.ConnectionProxyHandler.close:157 com.lge.ia.LIAServiceBase.finish:383 
2020-04-08 17:58:51.930 2627-2627/? I/LIA_SDK_V0.8.35_LogCore: LIA Log Close() - prefix : LIA_SDK_V0.8.35_
2020-04-08 17:58:51.931 2627-2627/? I/LIA_LogCore: LIA Log Close() - set context to null!!
2020-04-08 17:58:52.085 1838-2143/? I/WindowManager: Window{5d9148c u0 Application Error: com.test.debug} start dimming: flags=1820002 effectFlags=0, layer=111000
2020-04-08 17:58:52.124 2360-2360/? D/StatusBar: setSystemUiVisibility vis=8008 mask=ffffffff oldVal=8008 newVal=8008 diff=0
2020-04-08 17:58:52.126 5420-5467/com.test.debug W/FirebaseRemoteConfig: No value of type 'FirebaseRemoteConfigValue' exists for parameter key 'fpr_session_max_duration_min'.
2020-04-08 17:58:52.152 2844-2844/? D/TeleService: PhoneInterfaceManager: [PhoneIntfMgr] mSigLevel = 2
2020-04-08 17:58:52.154 2360-2584/? I/MobileSignalController: isRoaming = false
2020-04-08 17:58:52.154 2360-2584/? I/NetworkController: onReceive: intent=Intent { act=android.intent.action.SIG_STR flg=0x10 (has extras) }
2020-04-08 17:58:52.160 2360-2584/? I/MobileSignalController: isRoaming = false
2020-04-08 17:58:52.204 5420-5444/com.test.debug I/zygote64: Compiler allocated 4MB to compile void com.google.android.gms.internal.firebase-perf.zzgp.zza(java.lang.Object, com.google.android.gms.internal.firebase-perf.zzin)
2020-04-08 17:58:52.312 1838-1870/? W/ActivityManager: Activity pause timeout for ActivityRecord{1d7339c u0 com.test.activity.MyActivity t706 f}
2020-04-08 17:58:52.327 2795-3894/? D/LGImageQualityEnhancementService: handleCallbackActivity(), isEnhanced: false
2020-04-08 17:58:52.330 1348-1464/? I/PowerRM: System FW:1 IC:0 SO:0 GT:0 CAPP:-1 APP:0
2020-04-08 17:58:52.331 1348-1464/? E/PowerRM: found 42, mode set to 0
2020-04-08 17:58:52.354 2795-11577/? D/RoundCornerMask: ActivityTrigger mIsForceNotchMode : false , mIsSpecialMode : false
2020-04-08 17:58:52.356 2795-2795/? D/RoundCornerMask: mHandlerLand PORTRAIT 1
2020-04-08 17:58:52.423 2117-2126/? E/nightwatch-watcher: Failed to read from logcat: Success
2020-04-08 17:58:52.447 2360-2972/? I/SystemServicesProxy: RecentApps has 2 item(s).
2020-04-08 17:58:52.454 1838-3632/? V/LGSettingsProvider: call_put(secure:overview_last_stack_active_time=1586361483972)  calling package = com.android.systemui  callingUserId : 0
2020-04-08 17:58:52.556 2795-2795/? D/RoundCornerMask: mHandlerChangeResource::mIsStatusBarVisible : true , updateViewLayout:msg.what : 1
2020-04-08 17:58:52.688 809-4637/? D/sensors_hal_accel: handle_sns_std_sensor_event:89, accel_sample: ts=24727137016088 ns; value = [0.029731, 8.083754, 5.668999]
2020-04-08 17:58:53.423 2117-2126/? E/nightwatch-watcher: Failed to read from logcat: Success
2020-04-08 17:58:53.602 809-4637/? D/sensors_hal_accel: handle_sns_std_sensor_event:89, accel_sample: ts=24728070353797 ns; value = [0.034026, 8.070654, 5.685887]
2020-04-08 17:58:54.125 5420-5467/com.test.debug W/FirebaseRemoteConfig: No value of type 'FirebaseRemoteConfigValue' exists for parameter key 'fpr_session_max_duration_min'.
2020-04-08 17:58:54.426 2117-2126/? E/nightwatch-watcher: Failed to read from logcat: Success
2020-04-08 17:58:54.555 809-4637/? D/sensors_hal_accel: handle_sns_std_sensor_event:89, accel_sample: ts=24729003691505 ns; value = [0.031276, 8.080209, 5.671291]
2020-04-08 17:58:55.427 2117-2126/? E/nightwatch-watcher: Failed to read from logcat: Success
2020-04-08 17:58:55.469 809-4637/? D/sensors_hal_accel: handle_sns_std_sensor_event:89, accel_sample: ts=24729937029213 ns; value = [0.027177, 8.078901, 5.672119]

0 个答案:

没有答案
相关问题