Posts by Thiago Luiz Domacoski • 7,310 points
323 posts
-
1
votes1
answer57
viewsA: How to migrate from Notificationmanager to Notificationcompat in API 23
Change n.NotificationManager(context, notifTitle, notifMessage, pIntent); for : n.setContentIntent(pIntent); to pass the PendingIntent for your Notification.Builder…
androidanswered Thiago Luiz Domacoski 7,310 -
0
votes1
answer93
viewsA: Turning UTC milliseconds into other Time Zone
I got it this way by adding the getOffset timezone. public static long convertToTimeZoneDefault(final long time, final TimeZone zone){ final Date localTime = new Date(time); final Date fromGmt = new…
javaanswered Thiago Luiz Domacoski 7,310 -
2
votes1
answer54
viewsQ: Check that Simulated Locations are active
I’m developing an app that will use GPS to record a route. There are applications ( an example ) , which simulate its location. This is done through a development option : I wonder if it is possible…
-
1
votes2
answers89
viewsA: How to read a txt file store the value in the whole type?
As @Paulo Rodrigues said, you can use the method getIdentifier resource. Follows the documentation Example of use: try { AssetManager assetManager = getResources().getAssets(); InputStream…
-
1
votes1
answer93
viewsQ: Turning UTC milliseconds into other Time Zone
I receive from a service the date in milliseconds and UTC. I need to turn into the User Time Zone. For that I did the following: public static void main(String[] args) { // Milisegundos está em…
javaasked Thiago Luiz Domacoski 7,310 -
0
votes3
answers1124
viewsA: how to show data from a sharedPreferences in a Listactivity
Here’s an example of how to catch a Set<String> : // Pegamos a lista do SharedPreferences Set<String> itens = sharedPreferences.getStringSet(ITENS_LISTA, null); if(null == itens){ // Se…
-
0
votes1
answer89
viewsQ: Build with problems
Follow the project settings: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.0' } } allprojects { repositories { jcenter() } } apply plugin:…
-
0
votes1
answer499
viewsQ: How to generate signed apk with different keys
My problem is this I have an app on Google Play that I climbed some time ago. Create a key and its respective passwords. Now I made some improvements and when I went to generate the signed apk I…
androidasked Thiago Luiz Domacoski 7,310 -
0
votes1
answer23
viewsQ: Doubt about NS_ENUM
I have the following question about NS_ENUM I’m creating one with three options: typedef NS_ENUM(NSInteger, VersionStatus) { OPTION1, OPTION2, OPTION3 }; How do I use Lse inside a switch? Where the…
objective-casked Thiago Luiz Domacoski 7,310 -
5
votes1
answer907
viewsA: How to list the name of the files that are in the directory?
When you use the System.out.println(arquivo); is actually printing the getPath(). follows the documentation To print the name, try this way: public static void getImgs(String path){ File file = new…
-
3
votes3
answers1175
viewsA: Using Double in the compareTo method
Try it this way: Collections.sort(lst, new Comparator<Empreendimento>() { @Override public int compare(Empreendimento o1, Empreendimento o2) { if(o1.getPrecoMenor() > o2.getPrecoMenor()){…
-
0
votes1
answer26
viewsA: Low performance when converting Blob to Bitmap
I don’t know if it’s faster, but I’ve always used this form: byte[] byteArray = cursor.getBlob(columIndex); Bitmap bm = BitmapFactory.decodeByteArray(byteArray, 0 ,byteArray.length); And I never had…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes2
answers127
viewsA: Class that cannot be serialized
When an object is serialized in Java, this byte sequence, in addition to containing its nontransient instance attributes, carries with it a number that identifies the "version" of the class that was…
-
0
votes2
answers510
viewsA: Vector Comparison Problem - Java
Try it like this: int[] listaA = {2, -5, -121, 102, -35, -2, 0, -125, 802, -10}; int[] listaB = {6, 99, -1, 12, 1, -2}; int[] todos = new int[listaA.length+listaB.length]; int pt = 0; for(int i :…
-
1
votes1
answer311
viewsA: Set cryptographic key fixed
In fact your key is already fixed! Note that to create your Secretkeyspec, you use the bytes of SEED_16_CHARACTER. Summing up the constructor: //cria um MessageDigest de SHA-256 MessageDigest digest…
-
1
votes2
answers428
viewsA: Multiple sorts with Arraylist
Suggestion: Change the sorting methods to public instead of private, so you can use anywhere else. To make the call, the methods are static and are inside the right Person? Then it would look like…
-
2
votes1
answer109
viewsA: Return existing dates between two other dates - Android
Try the following: EDITED As reported in the commentary, there is a need to decrease 1 in the month to set a Date (String) in a Calendar. Example: final String[] valI = inicio.split("/");…
androidanswered Thiago Luiz Domacoski 7,310 -
5
votes1
answer1252
viewsA: Android Encryption and Encryption
Come on: I believe there are no errors in the Encrypt methods, but there is when you take the value of the screen: String codigo = encripta.encrypt(txtMensagem.toString()); Actually you are passing…
-
2
votes1
answer77
viewsA: Compare SMS data with txt file
If the amount is too large, I suggest you save the information in a database. Otherwise, to read a file txt located in the Assets folder : public void searchCode (String smsCode){ try { AssetManager…
androidanswered Thiago Luiz Domacoski 7,310 -
0
votes1
answer380
viewsA: View Route Google Maps button automatically
I decided as follows. I removed the default map option : mMap.getUiSettings().setMapToolbarEnabled(false); And I implemented two buttons to perform the actions: ImageView routeButton =…
-
0
votes1
answer380
viewsQ: View Route Google Maps button automatically
I have the following method for creating the Marker in the App: private void createMarker() { MarkerOptions mo = new MarkerOptions(); LatLng latLng = new LatLng(mObjetoResumo.getLatitude(),…
-
3
votes2
answers4120
viewsA: Question about reading txt files on Android?
Come on: 1. The doubt is with more variables which command for him to jump align and store the value in the variable inside the while. This is done within the while: while((linha =…
-
1
votes0
answers61
viewsQ: Error when registering an RMI Service
I have the following Class representing a service: public class HelloImpl extends UnicastRemoteObject implements Hello { protected HelloImpl() throws RemoteException { super(); } @Override public…
-
15
votes3
answers590
viewsQ: Doubt about Inheritance
I have the following case: Avo.: public class Avo { public String quemEuSou(){ return this.getClass().getName(); } } Mae.java: public class Mae extends Avo{ @Override public String quemEuSou() {…
-
3
votes2
answers103
viewsA: String deserialization
Try it this way: Gson gson = new Gson(); Type listType = new TypeToken<List<Drivers>>(){}.getType(); String str = drivers.get(0).toString(); Drivers teste = gson.fromJson(str,…
-
1
votes1
answer121
viewsA: Error compiling project.Buildgradle
There is an error in buildscript Try it this way: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' } } Add classpath before declaring the…
-
1
votes1
answer75
viewsA: How to get access to methods onView, withId or Matches on Android?
I was able to add the following import s: import static android.support.test.espresso.Espresso.*; import static android.support.test.espresso.matcher.ViewMatchers.*; import static…
-
0
votes1
answer75
viewsQ: How to get access to methods onView, withId or Matches on Android?
I’m following this tutorial ! In it, displays this example: package com.example.android.testing.espresso.BasicSample; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import…
-
0
votes1
answer58
viewsA: How to create a variable that stores a value even if you restart the application or change scenes on Android?
An example of the use of SharedPreferences: /** * Classe encapsula as funcionalidades de leitura e gravação no SharedPreferences */ public class SharedPreferencesController { /** * Constantes…
-
1
votes1
answer93
viewsA: Error summing Edit Text fields using Onfocuschangelistener
You are going to String with the memory reference of the object: edPrecoDeVenda.toString() Try it this way: edPrecoDeVenda.setText(venda); With the getText(), you will take the value of the field !…
-
1
votes1
answer997
viewsA: To create a summation method where the result appears in the Edit text field
How do you use the TextWatcher to apply the mask, I suggest using the View.OnFocusChangeListener Problem: It will only work when the user focuses on one of the fields! Example of implementation:…
-
4
votes4
answers9539
viewsA: How to convert a string to date or date?
The SimpleDateFormat is intended to convert java.util.Date in String and vice versa. When building this object it is possible to inform which date pattern you want to transform or recover. If this…
javaanswered Thiago Luiz Domacoski 7,310 -
5
votes4
answers334
viewsQ: Advantages of Inner Class
Since I started programming for Android (I believe due to Google examples), I have a habit of creating internal classes for functionalities related to Activity. Example: If the Activity connect to…
-
2
votes2
answers675
viewsA: Error while trying to start another Activity via a button
There are two possibilities: It is likely that your Theme not of Actionbar support. Try to change it in the file styles.xml for this: <style name="AppTheme"…
-
6
votes1
answer1405
viewsA: I wonder if it is possible to have a phone mask in a text View
For this, let’s do just like TextView. But instead of going through one changeListener, let’s move on to String ready-made! In your class Mask,implement the following method: public static String…
-
5
votes1
answer2809
viewsA: How do I alphabetize my list?
To sort the list we will use the method sort class Collections. This method requires two parameters: The list that will be ordered. The interface Comparator, which will have the ordering logic. To…
-
1
votes1
answer226
viewsA: implementing onClick
Hello ! Here’s an example of what your OnCLick: int ponteiro = 0; private View.OnClickListener nextAction(){ return new View.OnClickListener() { @Override public void onClick(View v) { // vamos ver…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes2
answers4333
viewsA: How to resolve java.lang.nullpointerexception in sqlite application?
Hello! If it is this line that is occurring the problem : pst = conn.prepareStatement(sql); So your Connection is void! For it to work, first we have to add the Sqlite library to your project.…
-
1
votes1
answer72
viewsA: Debug sending email - java-mail-1.4.4
Reflecting on the comments, I reached the following conclusion: He needs a PrintStream right? And why create one? If I already own the System.out? So instead of creating a new one, I use what I…
-
1
votes1
answer72
viewsQ: Debug sending email - java-mail-1.4.4
I have following code: private static boolean envioTest(final String descricao, final String msg, final String to)throws MessagingException{ final Properties props = new Properties();…
-
1
votes1
answer365
viewsA: problems inserting html into a Json Java object
Hello don’t worry about this character, when decoding the JSONthe system will remove it: Follow an example on java: public static void main(String[] args) { try { JSONObject jsonObject = new…
-
2
votes2
answers187
viewsA: Error save data from sqlite register
Hello ! I couldn’t understand why the one was running JavaNullPointerException, when there should actually be a NumberFormatException. Come on: Where there should be a int you are passing the…
-
1
votes3
answers531
viewsA: Using Activity Methods in a Fragment
For this, you must make one cast in getActivity() UpdateMarker updateMarker = ((UpdateMarker)getActivity()); This will work only if it actually UpdateMarker for a while Activity of Fragment…
-
1
votes1
answer640
viewsA: How to recover json data from a URL using HTTP POST on android?
On Android we can use some libraries to assist in this task as the Volley or Okhttp. I will show an example with Okhttp: Let’s add the libraries in build.Gradle: dependencies { compile…
androidanswered Thiago Luiz Domacoski 7,310 -
3
votes1
answer416
viewsQ: Keep screen on v4.1.x
I have the following code to keep the screen always on: if (usuario.getTelaLigada()){ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } Works in version 4.4 and higher. But not…
androidasked Thiago Luiz Domacoski 7,310 -
-1
votes2
answers4781
viewsA: How to store data from a. txt file in an object - Java
See if it helps you: public class Exemplo { public static final String SEPARADOR = "#"; public static final String ARQUIVO = "cadastro.txt"; public static void main(String[] args) { Produto produto…
-
0
votes1
answer170
viewsA: Problem updating appcompat-v7
Reinstalled Android Studio, and everything started working again! Suggestion from Androiderson.
-
0
votes1
answer286
viewsA: Connection test
Actually the method works correctly, the problem is that the HOST does not accept ping!
-
-1
votes1
answer87
viewsA: Dialog appears only after it has been called
This will call the camera after 15 seconds: final Runnable runnable = new Runnable() { @Override public void run() { // Isto será chamdo após 15 segundos... Intent cameraIntent = new…
-
0
votes1
answer286
viewsQ: Connection test
I have an application that will send some packages to the server. I would like to before sending, check if the server is available. And for that, I did the following: public static boolean…