android - Catching app events from external library -


i'm working in external library needs catch touch events, , detect activities life cycles, struggle couple of days till figure out way go, started flurry does, means? passing activity context main class in library. after that, thinking getting root view context can have access children views somehow, , assign touch listener event each one.

public class mainlibraryclass {    private context context;     private viewgroup rootview;     public void init(context context) {        this.context = context;         // parent view form context related        rootview = (viewgroup) ((activity) context).getwindow().getdecorview()             .findviewbyid(android.r.id.content);     initevents(); } 

this way assigned touch listener event root view

rootview.setontouchlistener(customtouchlistenerevent); 

and works, @ least main view, element on (buttons, image views, textviews, etc) :(

the solution passed mind current activity , every single view on this, , assign new touch event listener:

   private void getcurrentactivity() {     activitymanager = (activitymanager) context             .getsystemservice(context.activity_service);     list<activitymanager.runningtaskinfo> taskinfo = am.getrunningtasks(1);      componentname componentinfo = taskinfo.get(0).topactivity;     componentinfo.getpackagename();      // todo read , assign touch events views on activity } 

after read last response of this question realize setting new touch event listener every single view (again) gonna super mess time wondering if there way event in library without duplicate listeners or how can access events , activities context?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -