Android TextView Android dashboard is inconsistent

I have an application for studying the sacred Indian texts, usually consisting of a verse and commentary on this verse. To open it, I use the DisplayText activity that is called by the ActionBar when the user selects text from a verse or comment.

My problem is that it works inconsistently - on my Samsung Galaxy Note 2 it works fine, but on sony xperia Z2, when I try to touch the action button, it exits from the action panel and nothing happens.

The Android version for Samsung is 4.4.2 and the version for Sony 4.4.4

Please watch this very short video for your Sony device and how it works on your samsung device. Please note that error messages are not displayed in the LogCat view.

I would appreciate any suggestions on how I can fix this problem. Any ways to get a job would also be appreciated.

public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        //Log.v("DEBUG", "DisplaTEXT onCreate - Starting Activity");
        try
        {
             m_context=this;
         mtxtTransl2View.setCustomSelectionActionModeCallback(new CustomTextSelectCallback(mtxtTransl2View, false));
                     mtxtComment.setCustomSelectionActionModeCallback(new CustomTextSelectCallback(mtxtComment, true));

        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

    }


@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
class CustomTextSelectCallback implements ActionMode.Callback {
    public CustomTextSelectCallback(TextView tv, boolean b) {
        mTextView=tv;
        mbPurport=b;
    }

    //flag that selection is made in the purport, otherwise it is in shloka or translit

    private TextView mTextView;
    private boolean mbPurport;


    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        //Log.d(TAG, "onCreateActionMode");
        //if(mbPurport)
        { 
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.text_selection_menu, menu);

            MenuItem item = menu.findItem(R.id.cab_menu_fb);
            ShareActionProvider actionProvider = (ShareActionProvider)item.getActionProvider();

            actionProvider.setShareIntent(createShareIntent());             

            actionProvider.setOnShareTargetSelectedListener(new OnShareTargetSelectedListener(){
                public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) 
                {

                    try
                    {
                        getShareSubject("Share Subject","Please describe why would you like to share this (optional):");
                    }

                    catch(Throwable e)
                    {
                        String err="Error11: " + e.getMessage();
                        Toast.makeText(getApplicationContext(), err, Toast.LENGTH_LONG).show();
                    }       

                    if(mShareSubj.equals(SUBJ_CANCEL)) return false;

                    int start = mTextView.getSelectionStart();
                    int end = mTextView.getSelectionEnd();          
                    int tvID=mTextView.getId();
                    String sPlaceType = (tvID==R.id.textTransl2) ? "t":"p";
                    mTextURL=mTextURL+"?t="+sPlaceType+"&s="+start+"&e="+end;

                    mANText=mTextView.getText().subSequence(start, end).toString();

                    if ("com.facebook.katana".equals(intent.getComponent().getPackageName()) ) 
                    {
                        //mfacebooksharer.shareStatus(subject, text);
                        // Toast.makeText(this, "Facebook sharing", Toast.LENGTH_LONG).show();
                        shareOnFacebook();
                        return false;
                    }
                    else
                    {
                        if(!MyApp.mC.hasFlag(Cookies.FL_Sharing, m_context))   
                            return true;
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        intent.putExtra(android.content.Intent.EXTRA_TEXT,   getShareBody(intent));
                        intent.putExtra(android.content.Intent.EXTRA_SUBJECT, mShareSubj);

                        getApplicationContext().startActivity(intent);

                        return true;
                    }


                }

            });
        }

        return true;
    }

    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {

        return false;
    }

    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
        //Log.d(TAG, String.format("onActionItemClicked item=%s/%d", item.toString(), item.getItemId()));

        int start = mTextView.getSelectionStart();
        int end = mTextView.getSelectionEnd();
        long note_id=-1;

        mANPlace=UserDataSQLHelper.NOTE_PLACE_TEXT;
        mANText=mTextView.getText().subSequence(start, end).toString();
        if(mbPurport) 
            mANPlace=UserDataSQLHelper.NOTE_PLACE_COMM;

        mANStartPos=start; 
        mANEndPos=end;
        mScrollPos = mScrollT.getScrollY();

        switch(item.getItemId()) {

        case R.id.cab_menu_fav:

            if(!MyApp.mC.hasFlag(Cookies.FL_TextHighlight, m_context)) return false;

            note_id=MyApp.mUserDB.addNote(m_dbtype, m_dblang, mCurrBookID, mCurrSong, mCurrChapterNum, mCurrTextNum, mRowID, UserDataSQLHelper.NOTE_TYPE_HIGHL, mANPlace, start, end, mScrollPos,
                    mANText, "", "");

            break;
        case R.id.cab_menu_comment: 
            if(!MyApp.mC.hasFlag(Cookies.FL_TextHighlightAddCommentsQuestions, m_context)) return false;

            Intent intent = new Intent(getApplicationContext(), NoteEditor.class);
            intent.putExtra("NOTEEDIT_ACTION", NoteEditor.ACTION_ADD);
            intent.putExtra("NOTEEDIT_TITLE", "Add Question or Note");

            startActivityForResult(intent, SUBACT_ADDEDITNOTE);
            break;

        }
        if (note_id!=-1){ 
            ReloadText();
            AddTags(note_id);
        }
        return false;
    }

    public void onDestroyActionMode(ActionMode mode) {
    }
}

The text text of the xml code is here:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >


       <item
        android:id="@+id/cab_menu_fb"
        android:orderInCategory="10"
        android:showAsAction="always"
        android:icon="@drawable/cab_facebook"
        android:actionProviderClass="android.widget.ShareActionProvider"
        android:title="@string/cab_menu_fb"/>

    <item
        android:id="@+id/cab_menu_fav"
        android:orderInCategory="20"
        android:showAsAction="ifRoom"
        android:icon="@drawable/cab_highl"
        android:title="@string/cab_menu_fav"/>


      <item
        android:id="@+id/cab_menu_comment"
        android:orderInCategory="30"
        android:showAsAction="ifRoom"
        android:icon="@drawable/cab_comment"
        android:title="@string/cab_menu_comment"/>

</menu>
+4
source share

All Articles