Posts by Thiago Luiz Domacoski • 7,310 points
323 posts
-
2
votes2
answers4016
viewsA: Creating more than one Android Studio table (Sqlite)
If understood, you want to create the table and already insert the values? You can perform as many operations as needed on onCreate. Follow an example: @Override public void onCreate(final…
-
1
votes1
answer139
viewsQ: Get meta-data from Androidmanifest
I’m developing a library. For use the developer must inform a usage key. I would like to use the same way as Google maps: <meta-data android:name="com.google.android.geo.API_KEY"…
-
0
votes1
answer468
viewsA: Java Runtime.getRuntime(). exec() Does not execute commands with space
Try to 'Clean' the String before executing the command: String sentence = null; sentence = new String(pacoteRecebido.getData()).trim(); It happens that when sending your String, he will complete the…
-
0
votes1
answer934
viewsA: Share PDF
The error occurs due to the way the Uri is caught from the file: final String filePath = file.getAbsolutePath(); final Uri arquivo = Uri.parse( filePath); For internal files should be used…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes1
answer934
viewsQ: Share PDF
I have an application that generates a pdf from an internal content. I need to share this pdf, and for that, I do it as follows: final String filePath = file.getAbsolutePath(); final Uri arquivo =…
androidasked Thiago Luiz Domacoski 7,310 -
0
votes1
answer174
viewsA: Error in getWritableDatabase()?
As it is displayed in the error, the problem is in the SQL creating the tables in the database! Missing spaces, try the shape sequinte: String sql1 = "CREATE TABLE "+TABELA1+" (" + CELULAR + "…
-
2
votes1
answer420
viewsA: Error while casting Edittext
In your xml: <TextView android:id="@+id/alteracaoNome"..... In java: nomeAlterado = (EditText) findViewById(R.id.alteracaoNome); As stated in the error, it is not possible to perform the cast…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes2
answers2975
viewsA: Check if 'Allow dummy locations' is enabled
Complementing the answer, the object Location has a property informs if it was generated by mock, isFromMockProvider. This is available from API 18. Example: if(!location.isFromMockProvider()){ //…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes1
answer104
viewsA: Open the app with open navigation. How can I do this implementation in my code?
From what I’ve seen, this is the implementation of Materialdrawer According to the documentation, follow the example to open the Menu: final Drawer navigationDrawerLeft = new DrawerBuilder()…
-
3
votes4
answers724
viewsA: Java: When to use Interrupt vs flags?
I understand that things are a little different! To use interrupt it is necessary that within your method run throw a InterruptedException, so that when calling the interrupt this bid to Exception.…
-
0
votes4
answers246
viewsA: Error using Collections.Sort()
I ran some tests and it worked! With the example cited above, the list is already organized! Then there will be no change in the list: [Number 10 account, Number 5 account, Number 2 account] [Number…
javaanswered Thiago Luiz Domacoski 7,310 -
1
votes2
answers143
viewsA: Separating a String, how do I do?
Try As Follows: String url = "intent://instagram.com/_u/fabiohcnobre/#Intent;package=com.instagram.android;scheme=https;end"; // Quebramos os valores onde há ; String [] vals = url.split(";"); // O…
-
0
votes2
answers607
viewsA: How to select a database blob and transform into bitmap?
Here’s a basic example of how to manipulate images in Sqlite: IMAGE: public void add( byte[] image) throws SQLiteException{ ContentValues cv = new ContentValues(); cv.put(KEY_IMAGE, image);…
-
0
votes2
answers102
viewsA: Delete onClick error
In his xml change the following property of RelativeLayout: OF: tools:context="com.allsport.miyonic.allsport.ResultadoSimples" FOR: tools:context="com.allsport.miyonic.allsport.ResultSimples"…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes2
answers132
viewsA: How to get information from Satellites through Locationservices
Just complementing the @ramaral response ! Implementation of GpsStatus.Listener: class GPSStatusCallBack implements GpsStatus.Listener { @Override public void onGpsStatusChanged(int event) { if…
-
2
votes2
answers132
viewsQ: How to get information from Satellites through Locationservices
There are app’s that show on how many satellites your GPS managed to communicate. Follow an exmeplo: https://play.google.com/store/apps/details?id=com.chartcross.gpstest I saw some examples where…
-
1
votes2
answers2784
viewsA: Code to capture signature
Follow an example: Drawview.java. import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes2
answers120
viewsA: Problem catching latitude and longitude android 5
Try it like this: private void checkPermission() { // Verifica necessidade de verificacao de permissao if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=…
androidanswered Thiago Luiz Domacoski 7,310 -
0
votes1
answer48
viewsA: Save object to a list not the reference
When you set the due date, (setDataVencimento ), you pass the object reference Calendar. To avoid this, use the method clone() In this case, it returns a Object, then we cast a cast:…
-
2
votes2
answers1200
viewsA: Loading/Loading screen
Try it this way: activity_main.xml <TextView android:text="Loading ... Please Wait" android:layout_width="wrap_content" android:layout_height="wrap_content"…
androidanswered Thiago Luiz Domacoski 7,310 -
2
votes1
answer1266
viewsA: How to plot a route using maps API
Welcome! Try it this way: // URL para abrir o google maps final String ulrRoute = "https://maps.google.com?saddr=Current+Location&daddr=%s,%s"; // Informe a latitude e longitude do local do…
-
0
votes3
answers109
viewsA: I made a Splashscreen it carries and it does not go to the Activity prixima what should I do?
I don’t quite understand your code, but this is possible to do with AsyncTask ! Follow an example : class Loader extends AsyncTask<Void, Void, Void>{ private Integer update = 1; @Override…
-
0
votes1
answer149
viewsA: Update on sqlite does not update data
Try to update as follows: db.update("tab", editContact, "_id = ?", new String[]{rec.getId().toString()}); db.close(); You can include ? in the clause WHERE, which will be replaced by the values of…
-
1
votes1
answer165
viewsA: How to resolve error: illegal Static declaration
For a Sub-Class to have static methods, it needs to be static as well! Its Sub-class DadosGuardados has 2 static methods (in addition to main) and she’s not static! Try to state it as follows :…
-
2
votes1
answer954
viewsA: GPS oscillating even when in a fixed location
The real accuracy of a device depends on the chipset, the location where you are ( in a closed place, tends to be more inaccurate), among others. The typical accuracy of a handheld GPS device would…
-
1
votes1
answer76
viewsA: java.lang.Nullpointerexception in method
The error is on the line 52, you try to use an object that has not yet been initialized! Here is an example of how to initialize Connection : Connection getConnection() { String DB_CONN_STRING =…
-
1
votes1
answer403
viewsA: Android - Connection to Postgresql
There is a need to load the Driver before connecting, second this documentation. Try it this way: public boolean conectarDB() { try{ //Carrega o driver Class.forName("org.postgresql.Driver"); String…
-
2
votes0
answers22
viewsQ: What is the function of << (two Less than) in Java?
I have the following method: private static String encode(long number){ StringBuilder builder = new StringBuilder(); number = number < 0 ? ~(number << 1) : number << 1; while (number…
javaasked Thiago Luiz Domacoski 7,310 -
3
votes2
answers1439
viewsA: What is the meaning of this line in Java?
The name of this type of parole is If ternary ( Ernary Operator ) Simplifying : ? == if : == else ( ( i != this.ultimo) ? ", " : ""); So if i != this.ultimo , concatene “ , “ , otherwise “:”…
javaanswered Thiago Luiz Domacoski 7,310 -
1
votes1
answer70
viewsA: Problem with android UPDATE
Try it this way: db.update("MY_TABLE", values, "KEY_ID = ?", new String[]{String.valueOf(KEY_ID)}); According to the documentation: You can include ? in the WHERE clause, which will be replaced by…
-
1
votes1
answer67
viewsA: Crashing when starts the 2nd Activity
MainActivity$SolicitaDados.onPostExecute(MainActivity.java:83) On the line 83 of MainActivity, there is an object that is null! It is likely that the Conexao.postDados(urls[0], parametros) is…
-
6
votes1
answer2476
viewsQ: Draw route over the street on the map
I have a feature that captures the positions of gps every 10 seconds. Every 30 seconds or if there’s a 20 degree change in the Bearing (Compare the last position with the current one) store to send…
-
0
votes1
answer94
viewsA: Nullpointerexception error in setMyLocationEnabled()
The method onMapReady returns the map loaded as parameter (googleMap). You need to pass the reference to the mMap! Try the following: @Override public void onMapReady(GoogleMap googleMap) { mMap =…
-
5
votes1
answer330
viewsA: How to receive external data via XML
Follows: import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.xml.parsers.DocumentBuilder; import…
-
2
votes1
answer71
viewsA: Bookmark is duplicated when updating User Location
Occurs the following: By invoking the marker.remove(); removes only the last reference! To solve, create two Marker’s: if(markerUm != null){ markerUm.remove(); } if(markerDois != null){…
-
1
votes1
answer610
viewsQ: Take a photo with the Front Camera without using obsolete Apis
I’m developing an app where when you login, you should take a photo! I looked into it and found the following example : public class PhotoHandler implements Camera.PictureCallback { private final…
-
2
votes2
answers642
viewsA: When I install apk it is installing more than once the app
If I understand correctly, when installing . apk, it creates two Apps, This is because there must be two Activity’s set as MAIN Check if in your AndroidManifest as Activity’s with the following…
-
3
votes2
answers57
viewsA: Nullpointerexception error when obtaining location
It occurs because the object Location is null. When he tries to access the variable location.getLongitude(), error! There is a more current way of picking up the location than the locationManager.…
-
2
votes1
answer110
viewsA: View Spinner Progressidialog?
Try As Follows: @Override protected void onPreExecute() { progress = new ProgressDialog(Login.this); progress.setTitle("Aguarde"); progress.setMessage("Logando..."); progress.show(); } In the…
-
0
votes2
answers475
viewsQ: Hide / Show Menu
I have the following menu: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_delete"…
androidasked Thiago Luiz Domacoski 7,310 -
3
votes2
answers3051
viewsA: Popular Spinner with Sqlite Database -
I believe you have encapsulated this information in an Object: Example: class Turma { private Integer id; private String nome; public Integer getId() { return id; } public void setId(Integer id) {…
-
3
votes1
answer106
viewsA: Configuring imagebutton in listview
Follow an example! /** * Criamos um ArrayAdapter com o tipo de Objeto que vamos trabalhar! */ class MeuAdapter extends ArrayAdapter<Objeto>{ public MeuAdapter(Context context, int resource) {…
androidanswered Thiago Luiz Domacoski 7,310 -
2
votes1
answer317
viewsA: Why is the Locationlistener onLocationChanged so inaccurate?
The actual accuracy of a device depends on the chipset, the location you are in ( in a closed place, tends to be more inaccurate) among others. All locations generated by Locationmanager include an…
-
2
votes1
answer80
viewsA: Json for android Markers
This requires a list! In the AsyncTask, changes the screen only in the method onPostExecute! Follows a suggestion: @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // se o…
-
0
votes2
answers287
viewsA: Cardview of welcome
As said, you can save this state on SharedPreferences: Follow an example: public static final String IS_SHOW = "IS_SHOW"; public static final String PREFERENCES = "PREFERENCES"; @Override protected…
androidanswered Thiago Luiz Domacoski 7,310 -
2
votes2
answers145
viewsA: Error compiling code with import java.util.Random; Random.nextInt()
Try As Follows: public class Random { public static void main(String[] args){ java.util.Random num = new java.util.Random(); System.out.println(num.nextInt()); } } In this way it is not necessary to…
-
0
votes2
answers322
viewsA: Search simple data Sqlite
I didn’t understand very well, and without the error that occurs it gets kind of difficult! But I have some considerations: The SUM function, returns the sum of the values, then returns only one…
-
2
votes1
answer58
viewsA: How to stay 'listening' to see if SMS arrived on Android
Follow an example: Add the following permissions to your Androidmanifest.xml : <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> <uses-permission…
androidanswered Thiago Luiz Domacoski 7,310 -
-1
votes1
answer68
viewsQ: Recyclerview reuse of View
I’m Implementing a RecyclerView as follows: class ObjAdapter extends RecyclerView.Adapter<ObjetoHolder>{ private RealmResults<Objeto> objetos; private final SimpleDateFormat sdf = new…
-
0
votes2
answers96
viewsA: Nullpointerexception when deleting register
When you instantiate the Object DBHelper the Context is still null! Try it this way: DBHelper dbHelper = null; public ProdutoViewHolder(View view, Context context, ArrayList<Produto> produtos)…