Closed glarimy closed 6 years ago
Complete this task by CoB tomorrow!
sir can you please provide the URL for fetching the answer.
http://www.glarimy.com/q?id={qid} where qid is the question's id.
For example, to fetch the answer for question with id 12, the following is the URL: http://www.glarimy.com/q?id=12
ok sir.
sir for the method implementation isConnected() in GlarimyQuestionService class
public boolean isConnected() { ConnectivityManager check=(ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE); }
1.getSystemService() shows error because it is unable to access from the nonActivity class because it doesnot have any context reference
I find a solution that creating a constructor in the GlarimyQuestionService with context parameter we get the reference through constructor and can access the getSystemService()
for example: public class GlarimyQuestionService implements QuestionService { Context context; public GlarimyQuestionService(Context context) { this.context=context; }
public boolean isConnected()
{
ConnectivityManager check=
(ConnectivityManager)**context.getSystemService**(Context.CONNECTIVITY_SERVICE);
}
}
sir please guide me to get out of this problem
This looks fine. You can send the context as constructor parameter to GlarimyQuestionService.
@ramakrishna5a1 ... you seem to checked in the code, but the issue is not updated with your remarks. Request you to make sure that you keep posting the comments in the issue board so that all other team members will come to know about the status.
The code looks fine. Closing the issue.
ok sir
sir issue no #23 implementing the GlarimyQuestionService
implemented url conneciton in public Question get() {} and public Answer getAnswer(int questionId) {}
i found that URL connection throws exception null and not getting the JSON string
It is because of url connection is attempt to open in the main thread.
and i have gone through different websites and found a solution that it can be done only in the background task and can establish a url connection.
an AsyncTask to be added for the GlarimyQuestionService to perform the Background Task .
i am experienced both the situations progrmatically.
sir now what i have to do sir.
Go ahead with async tasks
ok sir
sir i am still working on GlarimyQuestionService because some problems occuring after getting data from AsyncTask to MainThead i will fix very it soon sir.
sir all the situations in the GlarimyQuestionService are handled and added some more coding to do background task like handlers for better ui experience.
Bang! Good job.
Implement the GlarimyQuestionService class.