Kodeco Forums

Android: Intents Tutorial

In this Intents tutorial you'll learn what Intents are, the role they play in Android, and how to use them to communicate with other installed apps.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/590-android-intents-tutorial

I followed the tutorial to the dot (I think).
But I’m facing a issue. I tried solving but couldn’t get anywhere.

The app run as it should when the image is taken using the front facing camera of the mobile or when editing an already snapped pic.
However when I use the back camera, the image is snapped but on returning to the app, there is no image in the ImageView. The app proceeds to the next activity, and upon hitting the `Let’s Memeify’ button on this activity, the app crashes.

My mobile’s camera works fine though.

Kindly help me in resolving the issue.
This is my first ever post, so I don’t know what other data to include in this comment.

Hi!

Could you please share the phone model, Android version and the stacktrace would super-useful?

Thanks

Mobile: HTC Desire 616 dual sim
Android : 4.2.2

stacktrace:
(This is what I feel would be relevant, the part before and after the pic is snapped):

09-21 15:27:18.326 6996-6996/com.raywenderlich.memeify I/View: Touch down dispatch to android.widget.ImageView{41e63c08 V.ED…C. … 32,143-688,663 #7f030004 app:id/picture_imageview}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=317.51456, y[0]=328.51758, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=59681612, downTime=59681612, deviceId=3, source=0x1002 }
09-21 15:27:18.327 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:18.345 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59681641435502, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:18.347 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:18.359 6996-6996/com.raywenderlich.memeify I/View: Touch up dispatch to android.widget.ImageView{41e63c08 V.ED…C. …P… 32,143-688,663 #7f030004 app:id/picture_imageview}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=317.51456, y[0]=328.51758, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=59681654, downTime=59681612, deviceId=3, source=0x1002 }
09-21 15:27:18.410 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59681691100337, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:18.421 6996-6996/com.raywenderlich.memeify D/OpenGLRenderer: Flushing caches (mode 1)
09-21 15:27:18.433 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:18.444 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59681740764579, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:18.449 6996-6996/com.raywenderlich.memeify D/GraphicBuffer: create handle(0x68563ba0) (w:720, h:1184, f:1)
09-21 15:27:18.558 6996-6996/com.raywenderlich.memeify I/SurfaceTextureClient: [STC::queueBuffer] (this:0x68593360) fps:0.00, dur:379231.20, max:379231.20, min:379231.20
09-21 15:27:18.558 6996-6996/com.raywenderlich.memeify I/SurfaceTextureClient: [STC::queueBuffer] this:0x68593360, api:1, last queue time elapsed:379231.20
09-21 15:27:19.407 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:19.429 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59682717699656, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:19.430 6996-6996/com.raywenderlich.memeify D/OpenGLRenderer: Flushing caches (mode 0)
09-21 15:27:19.431 6996-6996/com.raywenderlich.memeify D/GraphicBuffer: close handle(0x68582c48) (w:720 h:1184 f:1)
09-21 15:27:19.431 6996-6996/com.raywenderlich.memeify D/GraphicBuffer: close handle(0x68563ba0) (w:720 h:1184 f:1)
09-21 15:27:19.437 6996-6996/com.raywenderlich.memeify D/Surface: [0x64e4adb8] ~Surface() +
09-21 15:27:19.437 6996-6996/com.raywenderlich.memeify D/Surface: [0x64e4adb8] ~Surface() -
09-21 15:27:19.437 6996-6996/com.raywenderlich.memeify D/Surface: [0x68593360] ~Surface() +
09-21 15:27:19.437 6996-6996/com.raywenderlich.memeify D/Surface: [0x68593360] ~Surface() -
09-21 15:27:20.160 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:20.160 6996-6996/com.raywenderlich.memeify V/PhoneWindow: DecorView setVisiblity: visibility = 4 ,Parent =ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{41e3fff0 I.E… R… 0,0-720,1184}
09-21 15:27:20.166 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59683462878041, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:25.443 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:25.448 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59688744885194, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:25.454 6996-6996/com.raywenderlich.memeify D/Surface: [0x68593360] ~Surface() +
09-21 15:27:25.454 6996-6996/com.raywenderlich.memeify D/Surface: [0x68593360] ~Surface() -
09-21 15:27:25.476 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:25.527 6996-6996/com.raywenderlich.memeify V/PhoneWindow: DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{41e3fff0 V.E… R…ID 0,0-720,1184}
09-21 15:27:25.642 6996-6996/com.raywenderlich.memeify D/skia: jpeg_decoder mode 0, config 6, w 2160, h 3600, sample 1, bsLength fb080!!
09-21 15:27:25.654 6996-6996/com.raywenderlich.memeify W/System.err: java.io.IOException: Mark has been invalidated.
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at java.io.BufferedInputStream.reset(BufferedInputStream.java:329)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at com.raywenderlich.memeify.BitmapResizer.shrinkBitmap(BitmapResizer.java:88)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at com.raywenderlich.memeify.TakePictureActivity$1.run(TakePictureActivity.java:139)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at android.os.Handler.handleCallback(Handler.java:800)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at android.os.Handler.dispatchMessage(Handler.java:100)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at android.os.Looper.loop(Looper.java:194)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5405)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
09-21 15:27:25.684 6996-6996/com.raywenderlich.memeify W/System.err: at java.lang.reflect.Method.invoke(Method.java:525)
09-21 15:27:25.685 6996-6996/com.raywenderlich.memeify W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:838)
09-21 15:27:25.685 6996-6996/com.raywenderlich.memeify W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
09-21 15:27:25.685 6996-6996/com.raywenderlich.memeify W/System.err: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
09-21 15:27:25.685 6996-6996/com.raywenderlich.memeify W/System.err: at dalvik.system.NativeStart.main(Native Method)
09-21 15:27:25.686 6996-6996/com.raywenderlich.memeify D/skia: — SkImageDecoder::Factory returned null
09-21 15:27:25.707 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59688993247085, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:25.737 6996-6996/com.raywenderlich.memeify D/GraphicBuffer: create handle(0x6853da68) (w:720, h:1184, f:1)
09-21 15:27:25.739 6996-6996/com.raywenderlich.memeify I/MALI: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
09-21 15:27:25.739 6996-6996/com.raywenderlich.memeify I/MALI: [Mali]max_allowed_dequeued_buffers=3
09-21 15:27:25.740 6996-6996/com.raywenderlich.memeify D/GraphicBuffer: close handle(0x6853da68) (w:720 h:1184 f:1)
09-21 15:27:25.745 6996-6996/com.raywenderlich.memeify D/GraphicBuffer: create handle(0x6853da68) (w:720, h:1184, f:1)
09-21 15:27:25.754 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: scheduleConsumeBatchedInput: mConsumeBatchedInputScheduled = false,mFirstPendingInputEvent = null, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
09-21 15:27:25.755 6996-6996/com.raywenderlich.memeify V/InputMethodManager: onWindowFocus: null softInputMode=32 first=true flags=#1810100
09-21 15:27:25.756 6996-6996/com.raywenderlich.memeify V/InputMethodManager: START INPUT: com.android.internal.policy.impl.PhoneWindow$DecorView{41e3fff0 V.E… R…ID 0,0-720,1184} ic=null tba=android.view.inputmethod.EditorInfo@42495a98 controlFlags=#104
09-21 15:27:25.762 6996-6996/com.raywenderlich.memeify V/InputMethodManager: Starting input: Bind result=InputBindResult{com.android.internal.view.IInputMethodSession$Stub$Proxy@424963f8 com.android.inputmethod.latin/.LatinIME #1182}
09-21 15:27:25.763 6996-6996/com.raywenderlich.memeify V/ViewRootImpl: doConsumeBatchedInput: frameTimeNanos = 59689059480194, this = ViewRoot{41e2adf8 com.raywenderlich.memeify/com.raywenderlich.memeify.TakePictureActivity,ident = 0}
.
.
.
(The crash because of empty ImageView):
09-21 15:27:42.758 6996-6996/com.raywenderlich.memeify I/View: Touch up dispatch to android.widget.Button{424ceae8 VFED…C. …P… 0,0-328,96 #7f03000b app:id/write_text_to_image_button}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=197.681, y[0]=10.167114, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=59706054, downTime=59705946, deviceId=3, source=0x1002 }
09-21 15:27:42.759 6996-6996/com.raywenderlich.memeify D/AndroidRuntime: Shutting down VM
09-21 15:27:42.760 6996-6996/com.raywenderlich.memeify W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x418e09a8)
09-21 15:27:42.760 6996-6996/com.raywenderlich.memeify W/dalvikvm: threadid=1: uncaught exception occurred
09-21 15:27:42.760 6996-6996/com.raywenderlich.memeify W/System.err: java.lang.NullPointerException
09-21 15:27:42.763 6996-6996/com.raywenderlich.memeify W/System.err: at com.raywenderlich.memeify.EnterTextActivity.createMeme(EnterTextActivity.java:161)
09-21 15:27:42.763 6996-6996/com.raywenderlich.memeify W/System.err: at com.raywenderlich.memeify.EnterTextActivity.onClick(EnterTextActivity.java:109)
09-21 15:27:42.763 6996-6996/com.raywenderlich.memeify W/System.err: at android.view.View.performClick(View.java:4248)
09-21 15:27:42.763 6996-6996/com.raywenderlich.memeify W/System.err: at android.view.View$PerformClick.run(View.java:17723)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at android.os.Handler.handleCallback(Handler.java:800)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at android.os.Handler.dispatchMessage(Handler.java:100)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at android.os.Looper.loop(Looper.java:194)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5405)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at java.lang.reflect.Method.invoke(Method.java:525)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:838)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/System.err: at dalvik.system.NativeStart.main(Native Method)
09-21 15:27:42.764 6996-6996/com.raywenderlich.memeify W/dalvikvm: threadid=1: calling UncaughtExceptionHandler
09-21 15:27:42.765 6996-6996/com.raywenderlich.memeify E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.raywenderlich.memeify.EnterTextActivity.createMeme(EnterTextActivity.java:161)
at com.raywenderlich.memeify.EnterTextActivity.onClick(EnterTextActivity.java:109)
at android.view.View.performClick(View.java:4248)
at android.view.View$PerformClick.run(View.java:17723)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5405)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:838)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)

The complete stacktrace

Thanks for the help.

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]