Out of memory when share to twitter

android
twitterkit

#1

When I use twitter kit sdk, after integrated the login and perform a share to twitter using:

TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
String photoPath = Environment.getExternalStorageDirectory().getPath() + “/Download/” + “test.jpg”;
Uri photoUri = Uri.fromFile(new File(photoPath));
final Intent intent = new ComposerActivity.Builder(MainActivity.this)
.session(session)
.image(photoUri)
.text(“Nice Game”)
.hashtags("#twitter")
.createIntent();
startActivity(intent);

Then I will receive an out of memroy excetption, and then the app will crash, here the logcat:

10-16 13:38:07.391 718-4290/com.example.app.twitter D/LeakCanary: In com.example.app.twitter:1.0:1.
* FAILURE in 1.4 6b04880:java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack available

                                                              * Reference Key: 5b91f036-1f34-46f7-8473-be4a745678bc
                                                              * Device: samsung samsung SM-N9008V hltezm
                                                              * Android Version: 5.0 API: 21 LeakCanary: 1.4 6b04880
                                                              * Durations: watch=5024ms, gc=146ms, heap dump=5659ms, analysis=38362ms
                                                              * Excluded Refs:
                                                              | Field: android.app.ActivityThread$ActivityClientRecord.nextIdle
                                                              | Field: android.view.inputmethod.InputMethodManager.mNextServedView
                                                              | Field: android.view.inputmethod.InputMethodManager.mServedView
                                                              | Field: android.view.inputmethod.InputMethodManager.mServedInputConnection
                                                              | Field: android.view.inputmethod.InputMethodManager.mCurRootView
                                                              | Field: android.animation.LayoutTransition$1.val$parent
                                                              | Field: android.view.textservice.SpellCheckerSession$1.this$0
                                                              | Field: android.support.v7.internal.widget.ActivityChooserModel.mActivityChoserModelPolicy
                                                              | Field: android.widget.ActivityChooserModel.mActivityChoserModelPolicy
                                                              | Field: android.accounts.AccountManager$AmsTask$Response.this$1
                                                              | Field: android.media.MediaScannerConnection.mContext
                                                              | Field: android.os.UserManager.mContext
                                                              | Field: android.appwidget.AppWidgetHost$Callbacks.this$0
                                                              | Field: android.sec.clipboard.ClipboardUIManager.mContext
                                                              | Field: android.media.AudioManager$1.this$0
                                                              | Field: android.widget.Editor$Blink.this$0
                                                              | Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
                                                              | Static field: android.media.session.MediaSessionLegacyHelper.sInstance
                                                              | Static field: android.text.TextLine.sCached
                                                              | Static field: android.widget.TextView.mLastHoveredView
                                                              | Thread:FinalizerWatchdogDaemon (always)
                                                              | Thread:main (always)
                                                              | Thread:LeakCanary-Heap-Dump (always)
                                                              | Class:java.lang.ref.WeakReference (always)
                                                              | Class:java.lang.ref.SoftReference (always)
                                                              | Class:java.lang.ref.PhantomReference (always)
                                                              | Class:java.lang.ref.Finalizer (always)
                                                              | Class:java.lang.ref.FinalizerReference (always)

My Device is Androoid Samsung Note3

Here is the demo I download and use:


#2

I finally figured it out :slightly_frowning_face:

just add
android.permission.INTERNET
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE

ok , I really not see the doc where it notify me that I should add these permission. I previously used
TweetComposer.Builder builder = new TweetComposer.Builder(this)
.text(“Nice Game”)
.url(url)
.image(photoUri);
builder.show();
It doesn’t need any permisson and I shared succeed. but when using Intent, I should add the permission