-1

I have been searching the same problem for days. But unable to get any hint for that.

I need to create an app like voodoo app, which shows its custom layout only on specific pages of different apps like flipkart,etc.

Now, till this time, i have found options of using AccessebilityService and MediaProjection classes for the same. But i am stuck, how can i know programmatically, that Flipkart's Product Detail Page is visible so that i can display my app's custom view over it like Voodoo app does.

Any suggestions?

1 Answers1

2

What you want to do is the following.

Using accessibility services track incoming events. Then you want to track TYPE_WINDOW_CONTENT_CHANGED events, and detect when the window content matches what you'd expect.

@Override
public void onAccessibilityEvent(AccessibilityEvent e) {

    switch (e.getEventType()) {
        case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:  {
            if (isFlipkartProdcutDetailPage(getRootInActiveWindow()) {
                doStuff()
            }
        }
    }
}
public boolean isFlipkartProductDetailPage(AccessibilityNodeInfo nodeInfo) {
    //Use the node info tree to identify the proper content.
    //For now we'll just log it to logcat.
    Log.w("TAG", toStringHierarchy(nodeInfo, 0));
}

private String toStringHierarchy(AccessibilityNodeInfo info, int depth) {
    if (info == null) return "";

    String result = "|";
    for (int i = 0; i < depth; i++) {
        result += "  ";
    }

    result += info.toString();

    for (int i = 0; i < info.getChildCount(); i++) {
        result += "\n" + toStringHierarchy(info.getChild(i), depth + 1);
    }

    return result;
}
MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • @PraneetKumar can you please share code exactly how you are tracking Flipkart Product Detail page ? How you are tracking when user first time opening product detail page and when user is coming from onPause() to onResume() because in both cases different events will be called? – Mahesh Apr 27 '16 at 12:57