Closed D3r3-k closed 3 years ago
Hey, This is a problem in your app code. As written in the stacktrace this is because you are trying to make a network call in the main activity (the main aka Ui thread). This is bad practice in Android since it would block the main thread which would lead to an app freeze as long as the call takes - if it takes to long your app would be killed. That's the reason why newer Android versions don't allow this anymore by default.
You could deactivate the restriction as described in this stackoverflow answer - but that would be, as formerly described, very bad practice and can lead to unexpected behavior.
Clean solution would be to execute the network call in a background thread. To archive this I would suggest to use a viewmodel and do the network call in a coroutine.
Another pitfall that can happen is that you forget to add permission to use internet to your app. To do so you have to add <uses-permission android:name="android.permission.INTERNET"/>
to your AndroidManifest.xml
I will try to provide a littel android app as documentation by example to the project within the next days.
I understand, I see that the error was mine, I will try to do the code again. If I have internet permissions, if I notice that, and I'm sorry to bother, but I have doubts, for any project is it recommended to use the same SDK as in the emulator or does it not matter much?
if possible could you explain both for kotlin and java? Thanks for the information, I would really appreciate those examples
hey @DrefKai i added an working android example --> https://github.com/skrapeit/skrape.it/blob/master/examples/android/README.md
hope it helps. if you have further questions regarding the library just let my know
Thank you so much! I will try to do it to take practice, I appreciate the examples!
I was reading your documentation and implemented version 1.1.1, but it didn't work, then I tried 1.0.0 because I thought it would be stable and it didn't work either. I think that maybe I am implementing it wrong or I am missing a library to be able to use it.
in my build.gradle (app) I have this
It is a new project so I have absolutely nothing, it is blank, in the manifest I have permission to use the internet and as a code in my activity I was testing it with the same documentation page
as the documentation does not have an example for the applications in android studio I did it like this because if or if it asks me to skrape this like this:
skrape (<HttpFetcher|BrowserFetcher|AsyncFetcher>)
in the examples that I saw in the documentation they only put
when executing the code that I did in the onCreate I get this
Could you guide me a little more to know how to use the library and implement it for my application?
Thanks