Questions tagged as 'android-studio'

1
answer

___ ___ erkimt problems StrictMode.ThreadPolicy ______ qstntxt ___

Hello, I have the link below

link

handing me a string %code% % type

%pre%

So, in %code% , handle it with% %code% below:

%pre%

This %code% % works normally. However, you need to put the code snippet below;

%pre%

Otherwise, the connection to the internet is NOT established.

However, I've added the INTERNET access permission on the %code% .

%pre%

But no use.

If I remove this block of code

%pre%

The connection to %code% does not.

The problem is that if I work that way, as often as the ones I need to access the %code% % is the same number of times you have to make use of this code snippet.

Is not there a general configuration file for this in %code% %?

Following the %code% % JsonClass

%pre%     
______ azszpr352394 ___

What happens is that your %code% tries to access the network (a blocking operation) in the main Android thread, which is not allowed.

You can read more about this , but to summarize: A The main Android thread is responsible for updating the views.

Doing blocking tasks such as accessing the network or the database in this thread causes the view to crash, giving that impression of lag in the application.

The above link also gives you an alternative to solve this problem: do this type of tasks within AsyncTasks .

I particularly prefer to delegate all this work to libraries like Retrofit .

Doing what you want with this lib is very trivial:

After adding dependencies , define the contract on an interface:

%pre%

Starts the service instance:

%pre%

And to consume the service in a non-blocking way, just call:

%pre%

Now, within the callback %code% you already have the webservice response parseada and ready to use.

    
___

Hello, I have the link below link handing me a string json % type {   "clientes":[      {        "idClientesT":"1",        "tipo":"s",        "nome":"Carlos"},      {        "idClientesT":"2",        "tipo":"s",        "nome":"Rogéri...
asked by 20.12.2018 / 14:43
1
answer

Using SeekBar in a simple way

I am, for study purposes, developing a player in Android Studio . The player is ready. Now I want to control it. Searching, I discovered the SeekBar component. But I'm not finding a way to tell her that the source of the sound is...
asked by 25.12.2018 / 15:13
1
answer

Black screen in android emulator

I'm trying to start the emulator by android studio and genymotion but in the two it gets a black screen in the emulator: It may be my graphics card that sucks, but would it have some way to fix it? Or some other decent emulator for and...
asked by 03.12.2018 / 15:07
1
answer

Error sending pdf to FirebaseStorage

I'm trying to send pdf files to the Firebase Storage and with this code I get to the point of getting the Uri, send, but only falls on onFailure, follow the code @Override public void onClick(View v) { if (Conte...
asked by 18.09.2018 / 08:01
1
answer

How do I execute the getCity () method with asynctask, and return the value of the string city to use in another method?

public class CadAnuncio extends AppCompatActivity { LocationManager locationManager; private Button btnSalvar; private DatabaseReference databaseAnuncio, databaseUsuario; private String uid, url, url02, url03, url04, url05,...
asked by 19.09.2018 / 14:53
1
answer

Insert Multiple Markers on Maps

I found a code here on the site, I put it in my project but it did not work, does anyone know how I can solve it? The method below is called in onViewCreated() Note: I'm using the Map within a fragment, can that be? public class Maps...
asked by 23.10.2018 / 01:09
1
answer

How to reuse a layout?

I want to create a screen with menu of essays, how do I "reuse" a layout to have several essays and less layout (xml) files.     
asked by 24.09.2018 / 18:56
1
answer

Opening an activity with a button

I'm having a problem opening my activity in various forums and have not found the answer. I have the activity "TelaDeLogin" and the activity "Feed", and already tried to open in several ways, here is the button xml code: <Button and...
asked by 10.07.2018 / 17:54
1
answer

Error opening a new Activity on mobile - Android Studio

Good morning everyone !!! So I'm new to programming for Android, I happen to have created 3 screens: Home Categories Attitude The main one is just for it to go either in Categories or Exit. The category he will choose in which of t...
asked by 19.07.2018 / 17:43