shubham_App sharma
shubham_App sharma

Reputation: 19

Floating Image Not Show in a Custom Activity In an android

When user gets a chatHeads or (Floating Image) by Facebook Messenger in a system. I have get the click event of floating Image. but My problem is when i am click on chatHeads or (Floating Image) and call a Activity, then call Activity properly but call chatHeads or (Floating Image) on a Above Activity. I want that to hide a chatHeads or (Floating Image) hide on custom Activity in an android.

public class MyAccessibilityService extends AccessibilityService
{
    @Override
    public void onAccessibilityEvent(AccessibilityEvent event)
    {
        if(getEventType(event).equalsIgnoreCase("default"))
        {
            Toast.makeText(getApplicationContext(), "Shubbham_test"+ event.getEventType(), Toast.LENGTH_LONG);
            Intent i = new Intent(getApplicationContext(),LoginScreen.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK  | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            i.putExtra(SMLockService.SERVICE_OPCODE,SMLockService.MSG_SERVICE_OPCODE);
            getApplicationContext().startActivity(i);       
        }
    }

    @Override
    public void onInterrupt() 
    {
        // TODO Auto-generated method stub
        Toast.makeText(getApplicationContext(), "Shubbham_test"+ "onInterrupt", Toast.LENGTH_LONG).show();;
    }

    @Override
        public void onServiceConnected()
        {
         AccessibilityServiceInfo info = new AccessibilityServiceInfo();
            info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
            info.packageNames = new String[]{"com.facebook.katana", "com.facebook.orca"};
            info.notificationTimeout = 100;
            info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
            setServiceInfo(info);
        }

    public String getEventType(AccessibilityEvent event) {
        switch (event.getEventType()) {
            case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
                return "TYPE_NOTIFICATION_STATE_CHANGED";
            case AccessibilityEvent.TYPE_VIEW_CLICKED:
                return "TYPE_VIEW_CLICKED";
            case AccessibilityEvent.TYPE_VIEW_FOCUSED:
                return "TYPE_VIEW_FOCUSED";
            case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED:
                return "TYPE_VIEW_LONG_CLICKED";
            case AccessibilityEvent.TYPE_VIEW_SELECTED:
                return "TYPE_VIEW_SELECTED";
            case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
                return "TYPE_WINDOW_STATE_CHANGED";
            case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
                return "TYPE_VIEW_TEXT_CHANGED";
        }
        return "default";
    }

    public String getEventText(AccessibilityEvent event) {
        StringBuilder sb = new StringBuilder();
        for (CharSequence s : event.getText()) {
            sb.append(s);
        }
        return sb.toString();
    }
}

Upvotes: 0

Views: 148

Answers (1)

M090009
M090009

Reputation: 1139

You can remove the floating image from the view in the click callback after launching the activity or just setVisibility(GONE).

Upvotes: 1

Related Questions