Posts by Piovezan • 15,850 points
395 posts
-
1
votes2
answers595
viewsA: Database in Android
If by "proper approach to achieve this goal" you mean which technology to use to make your webservices, choose the one you prefer. If you have more ease with Java, use Java, otherwise it is common…
-
7
votes2
answers1040
viewsA: When and why to create a mobile app?
Better understanding the question (which is more in line with "Why make an app when a responsive site in principle already manages?" and not of "What native features can prompt a company to want to…
-
1
votes1
answer33
viewsA: Follow/unFollow button on a lsitView populated by a request to a REST Webservice
I see no problem in already sending in the answer of the webservice the status "following" of each item (true or false, 1 or 0, or as you prefer). You see a problem with this? When the user touches…
-
2
votes4
answers1394
viewsA: How to concatenate two byte arrays in Java?
Try it like this: byte [] terceiro = new byte[mensagem.length + nonce.length]; for (int i = 0; i < terceiro.length; i++) { if (i < mensagem.length) { terceiro[i] = mensagem[i]; } else {…
-
1
votes2
answers895
viewsA: Calculation of the Z value of the normal distribution
The lines... double t=(60/365); double sigmat=(20/365); ...are giving zero because you are dividing whole. Try to do so: double t=(60.0/365.0); double sigmat=(20.0/365.0); Already the line...…
-
2
votes1
answer502
viewsA: How do I get a Surface to run a video using Exoplayer?
Try to get Surface how it is done in the official page demo application you quoted: exoPlayer.sendMessage(videoTrackRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE,…
-
4
votes2
answers11135
viewsA: Exception vs Runtimeexception, when using one or the other?
You asked for didactic examples. What I have is what I have learned from experience. In the case of checked exceptions I see that it is common for data manipulation libraries to release exceptions…
-
1
votes1
answer104
viewsA: Launch Exception on the onCreate of an Activity
In case of error "Unhandled Exception type Exception" that you mentioned, this code will not compile because Exception is a checked Exception, that is, the method by which the spear is obliged to…
-
5
votes2
answers1891
viewsA: How to design a basic socket client application
I ended up implementing part of these requirements and solving most of the doubts. Follows what I learned from this. Before though, a recommendation: socket on Android might not be what you want.…
-
1
votes4
answers3216
viewsA: How to know if the app is open
Drawn of that reply by Soen: You can take advantage of the activities lifecycle and maintain a flag indicating whether there is an Activity in the foreground. At the end of a transition from one…
-
1
votes1
answer50
viewsA: Execute method on all Activitys according to a range
If you want the 20-second counter to be restarted at each screen change, then do the activities extend an Activitycase, in whose onCreate() method the 20-second counter thread is started (only if…
-
1
votes2
answers747
viewsA: How to return calculations performed in Service to Activity?
Your Activity needs to wait for the result to be ready, and the service needs to notify Activity when it finishes the calculation. To do this, he needs to keep a reference from Activity, so he can…
-
1
votes1
answer352
viewsA: Resolve android.os.Networkonmainthreadexception error in an android application that works as a client to receive images from a server
On Android the main thread (also called UI thread, or user interface) is responsible for updating the graphical interface and therefore should be kept responsive, that is, it cannot be taken over by…
-
7
votes2
answers755
viewsA: What does the dereferenced compilation error mean in Java?
The variable letter is a char, which is a primitive type of data (a 16-bit integer without a signal). It is not an object. If it were an object (such as an String or a Character) you could call…
-
1
votes1
answer117
viewsA: Null pointer launch
This is the section that fails (line 32 is seek.setMax(i);): SeekBar seek = (SeekBar)findViewById(R.id.seek); seek.setMax(i); This is because seek is coming null from the findViewById(R.id.seek).…
-
9
votes2
answers3516
viewsQ: What is the right way to authenticate to a REST API used by mobile applications?
Actually there are two questions (with the right to subquestions). Today I have an already implemented token generation engine (inherited from a web application) that I am using in my REST* API for…
-
1
votes1
answer108
viewsA: Problem with programming logic in Java
Some lines are not where they should be. The class Carros became very short and contained only one constructor. All lines below it actually belong inside the class Carros. The class Carros so it…
-
2
votes2
answers5037
viewsA: Sort a list of objects by more than one attribute
Take your class Pontuacao implement the interface Comparable<Pontuacao> and implement in it the method compareTo(). Example with two criteria, criterion 1 being more important and criterion 2…
-
4
votes1
answer360
viewsA: Why does the app stop when I leave the field empty?
The error occurs before the check you are doing. Your application closes because by clicking the button the application tries to extract a type number double of the text contained in edtVao, that is…
-
2
votes2
answers467
viewsA: Diff without comparing spaces or line break
Winmerge does that. Just configure Edit > Options... > Compare
-
1
votes1
answer90
viewsA: How do I avoid infinite loopings in an array?
Given a position i,j in the forest, the neighbors of that position are: F[i-1][j-1] F[i-1][j] F[i-1][j+1] F[i][j-1] F[i][j+1] F[i+1][j-1] F[i+1][j] F[i+1][j+1] Every position you travel through the…
-
4
votes1
answer55
viewsA: Debug Sharedpreferences on Android
If you look at The Sharedpreferences API, You’ll see there’s a dodo getAll() that returns a Map with the key-value pairs contained in the preferences.…
-
2
votes1
answer174
viewsA: Chicken Escape - Backtracking Problem
I recommend you do not try to keep track of each animal’s positions manually. Instead use recursiveness and let the stack itself keep this history. This is what the algorithm of Flood-Fill…
-
4
votes1
answer841
viewsA: Difference between calling the Fragment call and a new instance
The way to initialize a new fragment with arguments is to save them in a Bundle and pass that Bundle to the fragment via setArguments(Bundle). This way the arguments passed by you will be preserved…
-
1
votes1
answer647
viewsA: Asynctask finish running
I confess with some shame that I have never tried this in my applications, although it is a feature that can be considered basic (interrupt an HTTP request), but I believe the following code will…
-
3
votes1
answer475
viewsA: Polymorphism with Arraylist
I’ve never tried to do and I don’t know if it violates the principle of Liskov’s replacement or anything, but I suggest the following: public interface ISalaoDAO<T> { int save(T object); int…
-
3
votes1
answer68
viewsA: Compiler error in code
The compiler gcc read your source code test.c and generated an executable file called test (without the .c). But instead of calling this executable (./test) you are calling the source code…
-
1
votes2
answers4842
viewsA: Bringing an Object for a Resultset
At each execution of rs.next() the cursor that "points" to the result brought by your SELECT down a line (contrary to what you may think it starts above the first line and not directly over the…
-
9
votes1
answer422
viewsQ: Object-relational impedance difference
Basic questioning about Object-Relational impedance Mismatch, a topic I have little experience with. It really exists? (I’m sure you do; Martin Fowler and Ted Neward already talked about the…
-
43
votes2
answers17995
viewsA: What is a context on Android?
(References: official documentation and two questions soen.) Context It is an access point for global information about a application environment. This is an abstract class whose implementation is…
-
2
votes1
answer177
viewsA: problem with spacing and starting with number
The regular expression below forces the table name to start with a letter or underscore (_) followed by other characters that can be letters, numbers, underscores or hyphens. if…
-
1
votes2
answers588
viewsA: What is the correct way to log in and register?
One way to do it is like this: public class AtividadeInicial extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);…
-
28
votes2
answers1891
views -
6
votes2
answers929
viewsA: Operator " | " in Java
The operator | is the "bitwise OR". It performs the bit-to-bit OR operation and as its name indicates serves to perform operations on the bits that make up integer variables.
-
5
votes2
answers1484
viewsA: How to return Latitude and longitude on Android Google-Maps
You want to perform an operation of geocoding. Use the method Geocoder.getFromLocationName(String locationName, int maxResults). It will return a list of objects Address, which in turn have the…
-
2
votes1
answer38
viewsA: Taking String values and separating them
Do so: String [] pedaços = resultado.split(";"); Each item of the array pedaços you will have one of the strings between semicolons. Example: Log.v("Teste", "Texto 1 = " + pedaços[0]); // Imprime…
-
2
votes2
answers508
viewsA: What is Dénsity and scaledDensity for on Android?
I gave the following use to density once (scaledDensity i never used): Imagine that you want to display an image prepared at runtime by you. Customize a figure, for example, and display it in a…
-
0
votes2
answers94
viewsA: GCM interacting with google maps
(Just so you know, the method GCMBaseIntentService.onMessage() is obsolete (deprecated), in its place should use an appropriate broadcast receiver and register with the GCM server with the class…
-
1
votes1
answer228
viewsA: Swipe to the right after left gives ANDROID error
The error is due to LayoutInflater try to add to the Activity layout a fragment that had already been added previously (trigger exception here). The reason for this is that the…
-
1
votes1
answer174
views -
1
votes2
answers246
viewsA: Change variable in a task
It is a matter of timing. The variable retorno may even be receiving the value of Content, but the part of the code that is reading the value of retorno must be trying to access it before the…
-
2
votes2
answers125
viewsA: ERROR IN THE INBACKGROUND
I believe inside updateJSONdata() you’re calling a Toast. This is not allowed because the Toast can only be called in the main thread, which is responsible for screen updates, while the method…
-
2
votes1
answer347
viewsA: How to create a Treemap to store words and lines where they appear?
Make a: TreeMap<String, List<Integer>> mapeamento = new TreeMap<String, ArrayList<Integer>>(); So you will have for each word (String) a list of lines in which it occurs.…
-
2
votes1
answer144
viewsA: Android - take the splash screen from the back-stack
See if this solves: @Override public void run() { Intent login = new Intent(this, LoginActivity.class); startActivity(login); finish(); }
-
5
votes3
answers422
viewsA: Doubt about extends Application
There is no such thing in Java, it’s a Android thing. In Java you can even invent a class Application for its application, but will not be like the android.app.Application Android, that is, there is…
-
3
votes3
answers1027
viewsA: Connect android screen
The solution is the BroadcastReceiver call a Activity which when displayed will cause the screen to be switched on and, if necessary, unlocked (Unlocked). This is done as follows: public class…
-
4
votes1
answer112
viewsA: Thread Safe and its link to Collections
How should you know, if more than one thread access the same object may occur competition problems (conflicts/inconsistency in the data that this object contains, that is, in the state of that…
-
0
votes1
answer1503
viewsA: Broadcast notification when Android device is asleep
Who has to have a Wake Lock to keep the CPU awake is the broadcast receiver and not the code that schedules the alarm next to Alarmmanager. I suggest your broadcast receiver be a subclass of…
-
2
votes1
answer53
viewsA: Fragmentactivity in tab Swiper
You can’t call it. The method getItem() returns a Fragment, which is different from FragmentActivity, that despite being a Activity own to contain Fragments, still is a Activity and not a Fragment.…
-
1
votes1
answer21877
viewsA: How to wake up the screen only by touching the android screen
It is not a conventional Android feature but a modified ROM called Elementalx. In the video description there is a link to the version of this ROM for the Nexus 5 (functionality doubletap2wake).…