glarimy / glarimy-quiz-app

The source code and resources for Glarimy Quiz community project
0 stars 0 forks source link

Implement com.glarimy.quiz.service.GlarimyQuestionService #23

Closed glarimy closed 6 years ago

glarimy commented 6 years ago

Implement the GlarimyQuestionService class.

glarimy commented 6 years ago

Complete this task by CoB tomorrow!

ramakrishna5a1 commented 6 years ago

sir can you please provide the URL for fetching the answer.

glarimy commented 6 years ago

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

ramakrishna5a1 commented 6 years ago

ok sir.

ramakrishna5a1 commented 6 years ago

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

glarimy commented 6 years ago

This looks fine. You can send the context as constructor parameter to GlarimyQuestionService.

glarimy commented 6 years ago

@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.

glarimy commented 6 years ago

The code looks fine. Closing the issue.

ramakrishna5a1 commented 6 years ago

ok sir

ramakrishna5a1 commented 6 years ago

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.

glarimy commented 6 years ago

Go ahead with async tasks

ramakrishna5a1 commented 6 years ago

ok sir

ramakrishna5a1 commented 6 years ago

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.

ramakrishna5a1 commented 6 years ago

sir all the situations in the GlarimyQuestionService are handled and added some more coding to do background task like handlers for better ui experience.

glarimy commented 6 years ago

Bang! Good job.