Posts by Piovezan • 15,850 points
395 posts
-
4
votes1
answer783
viewsA: Error with GET HTTP Special characters
These constructions of the type & and ã are called HTML Character entities. They are not errors and probably already came from the original page like this. They are used to…
-
2
votes1
answer42
viewsA: Class context problem
The builder of the class StreamingMediaPlayer requires an object Context. On Android, Activities are examples of valid contexts. In the case of your fragment, the context, that is the Activity that…
-
1
votes1
answer100
viewsA: How to adapt an Activity to Fragmentactivity
Try using findViewById in the onCreateView() fragment method like this: rootView.findViewById(id); Inside the fragment but outside onCreateView() do so: getView().findViewById(id); For other…
-
10
votes4
answers756
viewsA: Remove a specific space in a string
String comEspaco = "8 hrs 2 mins"; String semEspaco = comEspaco.replace(" hr", "hr").replace(" min", "min"); Alternative solution with regex without depending on what comes after each space: String…
-
1
votes2
answers395
viewsA: How to improve mongoDB query performance in collections with millions of records and each with many searchable attributes?
(Note: I am not DBA. And test anything on a separate copy of the bank before applying in production). With regard to indices Mongodb is not so different from relational banks. They are typically…
-
1
votes1
answer231
viewsA: How the Google Play Books app "blocks" books
I’m not sure if this is what Play Books does (it probably is), but every Android app runs as its own Linux user and has a directory that only this user (and therefore the application) can access.…
-
2
votes1
answer244
viewsA: Use a class in another class
In SocialFragment do: MainActivity mainActivity = null; @Override public void onResume() { super.onResume(); mainActivity = (MainActivity)getActivity(); } @Override public void onPause() {…
-
4
votes1
answer104
viewsA: Stackoverflowerror in recursive method when traversing folders and subfolders
Your recursive method percorre() is being called always with the same parameters. This is causing the execution stack to burst (successive calls piled up and exceeded the maximum amount allowed). I…
-
3
votes1
answer320
viewsA: How do I format the value of a double variable on android?
Try it like this: double dub = 31.2323232; meuEditText.setText(String.format( "%.2f", dub ));
-
8
votes3
answers11214
viewsA: What is Code Smell?
They are not the same thing. Many code Smells (bad smell in code) will follow these principles of DRY, KISS and YAGNI, which are prevalent in software development, but not all will (examples:…
terminologyanswered Piovezan 15,850 -
2
votes1
answer365
viewsA: Use of Actionbar Up Navigation Android - API23
Change FragmentActivity for AppCompatActivity (which is a subclass of FragmentActivity with support to action bar). So, in addition to being able to work with maps in your MapsActivity, will have…
-
21
votes3
answers14671
viewsA: What is the difference between Statement and Preparedstatement?
The difference goes beyond the simple addition of parameters. Most relational databases handle a query (query) JDBC / SQL in four steps: Interpret (parse) the SQL query; Compile the SQL query; Plan…
-
9
votes5
answers5756
viewsA: What is Design Pattern?
The problem of explaining what they are Design Patterns is that the explanation tends to be abstract, because the concept itself is somewhat abstract, and therefore for those who are beginners it…
-
18
votes2
answers17812
viewsA: What is a Thread? How does it work?
Threads in Java (the class java.lang.Thread) are abstractions of threads of the operating system. In the operating system A (or a) thread is a sequence of commands being executed in a program or…
-
4
votes2
answers1093
viewsA: What allows Java to find out which is the main class in a . jar
He doesn’t find out. The .jar usually includes a file called Manifest.mf inside the case META-INF and that contains a line indicating which is the executable class, similar to that: Main-class:…
-
3
votes1
answer858
viewsA: How to know which error of my android program?
Caused by: java.lang.ClassCastException: android.widget.Button cannot be cast to android.widget.ImageView 10-14 00:33:41.677: E/AndroidRuntime(12260): at…
-
3
votes1
answer147
views -
2
votes1
answer352
viewsA: Do not allow onBackPressed to run
To prevent the onBackPressed() do something about anything Activity just overwrite it on Activity in question: @Override public void onBackPressed() { // Não faz nada } But in your case I think the…
-
8
votes1
answer7446
viewsA: Where does the expression "brushing bits" come from, and what is the equivalent in English?
Bit twiddling or bit Bashing. Also bit diddling. Here the original definition of hacker meant "bit-brusher" or someone who loved programming. So - man -, you’re a hacker of the movement. Not in the…
terminologyanswered Piovezan 15,850 -
1
votes1
answer200
viewsA: Viewpager with different content on pages
Your code is always instantiating the same layout on each of the three pages (page_layout.xml). To fix this, create three different layouts (say, layout1.xml, layout2.xml and layout3.xml) in the…
-
3
votes2
answers588
viewsA: Pass Activity object id to another
Error happens because you are not passing an object Usuario but only your id, which is an integer. Pass a class object Usuario that will work. Note that you will need to do a "cast" (force type…
-
1
votes1
answer21
viewsA: How to make direct connection on the table?
No, it’s not. You do not connect directly to the table but to the database, in case scrum. Remove the part /usuario of your connection string. Once this is done, "IF" your user has access to the…
-
1
votes1
answer62
viewsA: Conditional Change of Activity
SharedPreferences anonacpref = getSharedPreferences("anonac", Context.MODE_PRIVATE); String texto = anonacpref.getString("anonac_texto", null); if (texto != null) { System.out.println("Já preenchido…
-
0
votes1
answer149
viewsA: Use of while in a Thread on Android(runOnUiThread)
Just run the call to SetAnimator() in the UI thread using runOnUiThread(), and the loop itself in the thread you created. Running the entire loop in the UI thread as you are doing will give problem…
-
1
votes2
answers115
viewsA: Security MYSQL Android
The correct is to do it by PHP (web service), so the application has no knowledge of the credentials used to access the database, and this portion of the code is isolated in the web service. In…
-
4
votes7
answers10560
viewsA: How to test if an Edittext is empty?
if (meuEditText.getText().toString().trim().equals("")) { .... Note that getText() never returns the value null, at worst it returns empty, ie, "". Optionally you can test length() == 0 or isEmpty()…
-
3
votes3
answers488
viewsA: Keep data from a list when rotating on Android
Does not overwrite onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState). Instead it overwrites onSaveInstanceState(Bundle outState). Ah, and in your case overwrite…
-
2
votes1
answer59
viewsA: Skip User registration activities already logged in the application
Your initial activity can be like this (note that there is no setContentView()): public class ActivityInicial extends Activity { @Override public void onCreate() { if (usuarioLogado()) {…
-
1
votes2
answers109
viewsA: Cancel Asynctask when choosing another menu item with Navigation Drawer
For you to cancel the AsyncTask, should call the method cancel() of the same. Must have a method responsible for calling cancel() in its fragment (let’s say this method is called…
-
0
votes2
answers252
viewsA: Login to an Android APP
EDIT: The problem seems to be in PHP, since Android works normally depending on which URL is called. I let the PHP people help. In his method onPostExecute(), try switching this line:…
-
1
votes4
answers374
viewsA: Is it recommended to use more than one Activity in an Android project?
Use more than one Activity is an option and not an obligation; with the advent of Fragments, you can have an app with a single Activity and several Fragments, that would effectively be the screens…
-
2
votes1
answer163
viewsA: Is it possible to request HTTP(POST, GET...) with android for any domain?
You will, but not because of Android, but because your server will need to be configured to accept connections from other domains. This is then a question more related to PHP than Android. Android…
-
1
votes3
answers126
viewsA: Is it safe to keep the context of an app in a Singleton?
As has already been said, the context of Activity shall not be maintained beyond the life cycle of the Activity. The ideal context to save is the global context of the application. I have a…
-
3
votes2
answers1185
viewsA: How to call a native app?
The difficulty is that some manufacturers replace the pure Android standard calculator (package com.android.calculator2) by their own apps, which stay in a different package, then it becomes…
-
0
votes3
answers958
viewsA: ANDROID: How to identify user screen density?
You can find out what the density category is (Density Bucket) to which the device belongs through of this question or by the @Wakim response, then pass this information as parameter for the request…
-
6
votes4
answers2064
viewsA: What are the main differences between Handler, Thread and Asynctask?
Thread A thread is a line of code execution within an application. An application can have multiple threads running at the same time. In other words, threads allow an application to behave…
-
15
votes3
answers4676
viewsA: Is the Finally block always run in Java?
The block finally will always be executed, except in rare situations. In general it is the guarantee that your code will release busy resources even if exceptions occur (Exceptions) or the method…
-
6
votes1
answer336
viewsA: Why serialize object to send in another Activity?
According to this issue in the English OS you need to serialize objects because they are passed to a class called ActivityManagerNative which is in a process separate from other applications. When…
-
10
votes3
answers420
viewsA: java.util.Map, best implementation considering just get(Object key)
Most likely HashMap, whose implementation is the simplest of the alternatives available: a simple scattering table non-synchronized, non-compete, unordered (in the sense that there is no guarantee…
-
4
votes1
answer244
viewsA: Is there a session variable in Json [web service]?
Just to clarify the nomenclature: JSON is not a method, it is simply a way to represent objects as a string. This form is used to transmit the data sent and received by the web services you write to…
-
1
votes1
answer79
viewsA: Google Cloud Messaging and Synchronization Standardization
After the user has completed the registration there may be a certain delay while the application registers with GCM, passes to your server the Registration id and your server sends the first push…
-
2
votes2
answers349
viewsA: Know if a class is native to JAVA or created by the User?
/** Testa se o pacote da classe começa com "java." ou "javax." * Talvez seja o caso de também testar os pacotes "org." listados em: * http://docs.oracle.com/javase/8/docs/api/overview-summary.html…
-
6
votes1
answer798
viewsA: What are the pros and cons of using jquery in mobile development?
This page recommends not using jQuery because it is a heavy library, and even jQuery UI and jQuery Mobile versions have poor performance, with jQuery Mobile in particular imposing a lot of rigidity.…
-
0
votes2
answers121
viewsA: Error when setting Background
The image is relatively large indeed. Different devices have different memory settings and a large image that is supported by one may not be supported by another. Resize the original image to…
-
1
votes2
answers103
viewsA: Start service through user action
You can try registering a receiver via code in your app, but I haven’t found any examples of this and it probably won’t work. GCM examples all record the receiver in Android Manifest.xml. This…
-
2
votes1
answer800
viewsA: How to receive a notification on android whenever there is a record in a table?
You can use push Notifications (GCM in the case of Android). First of all study the GCM. The moment you add a new entry to the bank, fire a request to send push notification to the GCM server. This…
-
1
votes1
answer129
viewsA: Algorithm resolution error summing Java arguments
Do so: public class Ex7 { public static void main(String[] args) throws NumberFormatException { int soma = 0; for(int i=0; i<args.length; i++) { int n= Integer.parseInt(args[i]);…
-
0
votes1
answer80
viewsA: Object Product Saved on the first screen but not on the second
Your code is holding in the object mProduto2 the content of the fields EditText empty and saving these values in the bank before you get to enter them. To correct this, change this section...…
-
3
votes3
answers366
viewsA: startActivityForResult inside an Adapter?
Although you can’t call the startActivityForResult() within your Adapter, you can register the Activity A as Listener (Observer) of Adapter, so that when the image is clicked the Adapter informs the…
-
1
votes1
answer956
viewsA: How to run my project Phonegap Cordova on a mobile with Android 2.3.6?
The latest version of Cordova does not support Android 2.3.6 because it is a version that is installed on less than 5% of Android devices currently: Cordova Supports Android 4.0.x (Starting with…