I have been trying to fix this error for a week now, but still cannot find the problem. The LogIn is working, but for some reason the share to Messenger Crashes. I cannot really understand what the problem is. Basically I save a text to speech to my device and then I attempt to share it. The file saves to the device (I checked), but messenger does not share.
Here is my code for sharing:
public void shareFile(View view) {
String sayWhat = "This is what you sound like when you write to me, thanks to the app Messenger Say it! Available now at Google Play";
HashMap hashmap = new HashMap();
hashmap.put("utteranceId", sayWhat);
String location = new StringBuilder(Environment.getExternalStorageDirectory().toString()).append("/").append(name).append(".mp3").toString();
speed = ((float)speedS.getProgress()/100F)*2.0F;
pitch=((float)pitchS.getProgress()/100F)*2.0F;
ttsread.setPitch(pitch);
ttsread.setSpeechRate(speed);
ttsread.synthesizeToFile(sayWhat, hashmap, location);
String mimeType = "audio/mpeg";
Uri contentUri = Uri.parse(location);
text.setText(contentUri.toString());
long futuretime = System.currentTimeMillis() + 1000;
while (System.currentTimeMillis() < futuretime) {
synchronized (this) {
try {
wait(futuretime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
ShareToMessengerParams params = ShareToMessengerParams.newBuilder(contentUri, "audio/mpeg")
.setMetaData("com.facebook.sdk.ApplicationId")
.build();
MessengerUtils.shareToMessenger(this, 1, params);
//MessengerUtils.finishShareToMessenger(activity,params);
}
and my logcat:
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3969)
at android.view.View.performClick(View.java:4637)
at android.view.View$PerformClick.run(View.java:19422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5586)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.view.View$1.onClick(View.java:3964)
at android.view.View.performClick(View.java:4637)
at android.view.View$PerformClick.run(View.java:19422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5586)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Unsupported URI scheme: null
at com.facebook.messenger.ShareToMessengerParams.<init>(ShareToMessengerParams.java:106)
at com.facebook.messenger.ShareToMessengerParamsBuilder.build(ShareToMessengerParamsBuilder.java:120)
at com.inc.nicky.messengersayit.PersonalSettings.shareFile(PersonalSettings.java:205)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.view.View$1.onClick(View.java:3964)
at android.view.View.performClick(View.java:4637)
at android.view.View$PerformClick.run(View.java:19422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5586)