• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

How to access non static content in the static block of an android application?

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm trying to access non static content in the static block, how to do it.
I tried to create an instance of the repository that I want to access which has retrofit OkHttpCall, which is failing when I create a new instance of that service.
I know we have @PostConstruct to use in spring, but it is not recognizing in the android studio, what is the annotation for it in the android?
I need to use non static service which returns a url need to be used in Intent() block.

Please help me on it.
 
Rancher
Posts: 4306
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the code that shows the problem?

To access non-static content in a class, you need an instance of the class and get or set methods in the class.
 
Lilly Rose
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my Service- ProxyKillSwitchRepository.java

it has a method which calls retrofit enqueue


and this been called in the same service in the method


I'm calling this service in the another activity file SupportWebViewActivity.java in the Intent() and I also want to access in the enum block on this activity


When I debug  through it, the instance is getting created and reaching the backend call but it is not coming back with response, it is just returning null as is it coming out the the mWebService.proxyKillSwitch().getAppConfig().enqueue().

I don't see anything it is reaching @Override public void onFailure(), the Is it because of any time with the enqueue call?

I did try to use @Inject annotation on the Service ProxyKillSwitchRepository in the activity SupportWebViewActivity,
@Inject
protected ProxyKillSwitchRepository proxyKillSwitchRepository;

this is coming fine and I see all the values of it, only problem I can't access this injected field in the enum or static Intent().

How to access the @Inject field in the static block?


 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic