Software design guidance needed (Android Library Project) -


  • i have app main activity ("mainactivity")
  • i have view in "android project library". use view in several apps, thats why added view in library.
  • i can use view app

but comes problem.

i interact apps mainactivity view.

if view in app insteed of library call...

(mainactivity)context.myfunction() 

... in view.

but in case of library, view doesn't know mainactivity, because out of project-scope.

how can interact activity view, placed in library ? hints ?

not sure if solution, post here. others.

i created interface in library project :

public interface interactactivity {     public void interact(string scommand, list<object> objects); } 

i implemented interface on activity :

@override     public void interact(string scommand, list<object> objects) {         // todo auto-generated method stub         if(scommand.equals("mycommand")){             ...         }     } 

then call method view (which in library project):

((interactactivity) context).interact("mycommand",myparameters); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -