I have a massage I want the user to share with other apps, so I do the following:
String shareBody = "content";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "title"));
The problem is that I get an Exception From the system and I can't figure out what am I doing wrong:
The Google Play services resources were not found. Check your project
configuration to ensure that the resources are included.
09-24 14:25:53.618 24079-24079/? E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@e2ecc0
09-24 14:25:53.618 24079-24079/? E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@1417df9
09-24 14:25:53.618 24079-24079/? E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@1417df9
09-24 14:25:53.868 24079-24177/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
Process: android:ui, PID: 24079
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.drawable.Drawable.getIntrinsicWidth()' on a null object reference
at android.app.ApplicationPackageManager.getThemeIconWithBG(ApplicationPackageManager.java:3062)
at android.app.ApplicationPackageManager.getThemeIconWithBG(ApplicationPackageManager.java:3037)
at android.app.ApplicationPackageManager.getDrawableForIconTray(ApplicationPackageManager.java:2933)
at com.android.internal.app.ResolverActivity.loadIconForResolveInfo(ResolverActivity.java:797)
at com.android.internal.app.ResolverActivity$LoadIconTask.doInBackground(ResolverActivity.java:2471)
at com.android.internal.app.ResolverActivity$LoadIconTask.doInBackground(ResolverActivity.java:2459)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
It happens only when i do sharingIntent.setType("text/plain");
. Does anyone know how to solve the problem?
Edit:
String shareBody = "really? I'm sending you a code to our awesome app!\nYour key:"
+ " "/* get key*/ + " Get started:" + " https://url";
Edit 2: Ok, so apparently it happens only on my Samsung galaxy s7 and not on the pixel. I also notice the log also shows:
09-24 14:48:44.888 31968-31968/? E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@e2ecc0
09-24 14:48:44.888 31968-31968/? E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@1417df9
09-24 14:48:44.888 31968-31968/? E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@1417df9