Posts by Thiago Luiz Domacoski • 7,310 points
323 posts
-
1
votes1
answer37
viewsA: Java Android - Save Events
You can save yourself in SharedPreferences! Follow an exmeplo: /** * CONSTANTES */ private String CONFIGRACOES = "#CONFIGRACOES"; private String CONFIGRACOES_ITEM_1 = "#CONFIGRACOES.ITEM_1"; private…
-
4
votes1
answer4841
viewsA: SHA-1 key problem in apk release and debug
When I go to work with some signed Api I usually generate the .apk signed debug, so I will only have one SHA-1. For that, put your .keystore at the root in your Project (at the same level as the app…
androidanswered Thiago Luiz Domacoski 7,310 -
0
votes1
answer45
viewsQ: Widget - Install automatically through the app
I would like to create a feature in the App to automatically add the Widget of the application. When the user clicks on a button, it automatically inserts the Widget on the home screen. It is…
-
0
votes2
answers282
viewsA: Like timing an Interstitial ad?
Try the following: private InterstitialAd mInterstitialAd; Long exibirAte; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);…
-
0
votes1
answer404
viewsA: Show user-installed apps only
Try the following: final List<ApplicationInfo> mAllApp = context.getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA); final List<ApplicationInfo> instalados = new…
-
2
votes1
answer58
viewsA: Auto Scroll for Specific View
Try it like this: vertical_scroll.scrollTo(0, exibirEste.getTop()); If the Element is not inside the vertical_scroll, the position of the parent should be taken into account: int position =…
androidanswered Thiago Luiz Domacoski 7,310 -
3
votes1
answer230
viewsA: Resources$Notfoundexception: Resource ID #0x7f060007 type #0x12 is not Valid
In the SimpleAdapter , must pass a layout, not a id: adapter = new SimpleAdapter(getActivity(), data, R.id.listView, from, to); To correct: adapter = new SimpleAdapter(getActivity(), data,…
androidanswered Thiago Luiz Domacoski 7,310 -
0
votes2
answers634
viewsA: Sort objects according to name attribute using Collections.Sort() or Reverse()
You implemented the Comparator in Main, right? Then you must pass to sort that the class Main is responsible for ordering! As you are in a static method, you should instantiate the class Main: Main…
javaanswered Thiago Luiz Domacoski 7,310 -
2
votes1
answer372
viewsQ: Sqlite MAX function - Grab the highest value
I have in the Sqlite a field called date_start, which saves the date of a walk. This one, it’s like Long and keeps the date on milisegundos. I would like, through a query, to return the highest…
-
0
votes1
answer198
viewsQ: Change the source via xml
I have the sources of my app on : main > Assets >fonts Is there any way to pass directly into xml? (android:typeface="") Or just via Java ?…
-
1
votes1
answer476
viewsA: Android Studio, how to collect data from other screens and show on the last screen?
There is a library that facilitates the transport of objects between classes. Is the Parceler! Follow an example: Add the following dependencies to your build gradles.: dependencies { … compile…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes1
answer645
viewsA: Android studio installing the app over another app
What identifies the App is yours applicationId: In his build.Gradle : defaultConfig { applicationId "com.me.pacote.exemplo" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0.0" }…
-
0
votes1
answer97
viewsA: I cannot save a query in the Database. Shows error Unfortunately
As pointed out by @Marcela Melo in the comments, this error occurs because there is some null object being accessed. To avoid this error you should test the properties before adding to your…
-
1
votes3
answers1366
viewsA: How to install an APK remotely? (how Googleplay updates apps)
You can do it this way: Service: Your Service can inform the app that there are new updates! Through a JSON (for example) you can specify the most current version. It is also possible to prevent a…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes1
answer743
viewsA: How to store the value of a variable in java after the end of the program?
For this, you can use a Serializable . In this case, you must create a file to store the information you want to save. Here’s a simple example of how to record and retrieve an object. This file will…
javaanswered Thiago Luiz Domacoski 7,310 -
3
votes1
answer3673
viewsA: Download files by link(url) Android
First, you will need the following permissions in your Androidmanifest: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission…
-
3
votes1
answer2550
viewsA: Grab photo from android gallery directly
Try the following: Open option: public static final int PICK_IMAGE = 1234; Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);…
-
2
votes1
answer2602
viewsA: Move File in Java
Try it this way: public static void main(String[] args) { // copia os dados InputStream in; // escreve os dados OutputStream out; try{ // arquivos que vamos copiar File toFile = new…
javaanswered Thiago Luiz Domacoski 7,310 -
0
votes1
answer113
viewsA: Help with Wifi Manager
Try it this way: wc.preSharedKey = senha.getText().toString(); The passwords is a EditText and what you want is the value of the text ( getText ). In this way : String.valueOf(senha) you’re taking…
androidanswered Thiago Luiz Domacoski 7,310 -
3
votes1
answer150
viewsA: Use of External class with error (non-static method)
This is because the method getSupportActionBar is not static, so it will not have access in a static method. There are two ways to resolve this situation: Abstract class This class will have all…
-
0
votes1
answer587
viewsQ: Add image to a collapsingtoolbarlayout
I would like to add a background image in a CollapsingToolbarLayout following this example: I tried it this way: <android.support.design.widget.AppBarLayout android:id="@+id/app_bar"…
-
2
votes1
answer105
viewsQ: Data Binding does not work
I’m trying to use the Data Binding on Android. For this I added the classpath in the application: buildscript { repositories { jcenter() } dependencies { classpath…
androidasked Thiago Luiz Domacoski 7,310 -
1
votes1
answer309
viewsA: How to save Cookies permanently and retrieve them later? [Android]
You can use the SharedPrefrences Follow an example: Class we will use to encapsulate the information we will save: public class User{ /** * Propriedades do Objeto */ private String nome; private…
-
18
votes4
answers870
viewsA: Why can an if be redundant?
The if requires a certain Boolean condition? then when you pass an expression (num >= 0), this will return a boolean. Forget the if, what is the function of your Method? Return true if it’s…
-
1
votes1
answer596
viewsA: Google drive api integration doesn’t work. how do I fix it?
It’s a little complicated to point out what’s wrong! Yet without an example, or link! I made a simple example of how to create a file: I won’t get into the merit of creating the credentials. If in…
-
2
votes1
answer716
viewsA: How to change the background color of the app popup menu
For this you must change the AppTheme.PopupOverlay Follow an example: <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"> <item…
-
4
votes2
answers684
viewsA: How to pass data from one fragment to another
Here’s an example of how to send: Adding to Fragment (this part you already do in your example): private static final String RESULTADO = "RESULTADO"; public static SegundoFragment newInstance(int…
-
0
votes1
answer47
viewsQ: App Engine - version problems
I’m trying to run a patch with the Google App Engine. But I get the following mistake: Description Resource Path Location Type Java Compiler level does not match the version of the installed Java…
-
1
votes2
answers190
viewsA: How could I get an image inside a <Scroolview to stay fixed and all the content "scroll" through the "bottom" of the image?
For this, one should use a RelativeLayout Example: <?xml version="1.0" encoding="utf-8"?> < RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"…
-
2
votes3
answers5170
viewsA: How do I leave a round image?
Here is an example of implementation: Roundedimageview.java import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas;…
-
3
votes2
answers1618
viewsA: How to use sharedpreferences as a class
In order to facilitate this leitura/gravação, I created a Generic class to store Classes in SharedPreferences: Below is the class and an example of Usage: Model Class: Sharedpreferencesmodel.java…
-
1
votes1
answer93
viewsA: Return results from a query
In fact, when waiting for a result, the function should be used db.query(); This returns a Cursor, with the result of your consultation: // Colunas que seu SELECT vai retornar String [] colunas =…
-
2
votes1
answer2285
viewsA: Coordinate - Latitude and Longitude Android
Here is an example of implementation ( Source ) First you should add the following permission into your AndroidManifest.xml <uses-permission…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes2
answers532
viewsA: Date and Time automatica
To do this, use the property AUTO_TIME . Here is an example of implementation: int type =0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { type =…
androidanswered Thiago Luiz Domacoski 7,310 -
3
votes1
answer225
viewsA: How to save user preferences?
For this (because it is little information) I suggest the SharedPreferences. For example, I created an object called User to facilitate data manipulation! Here is an example of implementation: /** *…
androidanswered Thiago Luiz Domacoski 7,310 -
5
votes2
answers923
viewsA: java.lang.Nullpointerexception: Attempt to read from field 'java.lang.String
The Error shows the following : to read from field 'java.lang.String com.project.meuapp2.elemento.dado' on a null object reference I mean, an object is null! Following the stack, the error occurs…
-
1
votes0
answers103
viewsQ: Turning Meters into Pixels
I would like to turn a metric value into pixels to add to a Marker. In earlier versions it used if as follows: import com.google.android.maps.Projection; Projection projection =…
-
1
votes2
answers1454
viewsA: Calling a new Activity through a Fragment
Try the following: In the statement of his xml put the following: <SeuLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"…
-
2
votes3
answers360
viewsA: Alarms are lost when mobile is turned off and on!
Just to complement the answer Add the following permissions: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED”/> Configure your receiver: <receiver…
-
2
votes1
answer47
viewsA: Function result JAVA Android
The apparent error is only in the Systemshttp class: MainActivity main = new MainActivity(); main.retornoLogin(resp); No instance of the Mainactivity class is required to return, who will do this is…
-
3
votes3
answers550
viewsA: Print the Thread ID
If I understand correctly, so you can print the ID of the Thread array, try the following : int indice_thread = 0; Thread[] thread = new Thread[NUMERO_DE_THREAD]; for (int linha = 0; linha <…
-
1
votes1
answer78
viewsA: Error trying to post a php page through Android Studio
The error occurs because it is likely that some Hasmap Postdata parameter is null! The stack says the error occurs in at…
-
0
votes1
answer155
viewsQ: Knowing if an app is open through a Broadcastreceiver
I have a BroadcastReceiver that displays a notification to the user! But if the user has the app open (with the screen active), I would like to cancel the notification! Is there any way to find out…
-
2
votes1
answer159
viewsA: How to create a style for Imageview on Android?
You can specify fixed file sizes dimens.xml which is in the folder res/values/. For screens with more than 820dp (screens of 7" and 10") you include in the file dimens.xml inside the folder…
-
2
votes1
answer77
viewsA: Display colors in percentage
For this you should know the total Pixels that the image has! For this do as follows: int totalPxls = 0; for(Palette.Swatch swatch : palette.getSwatches()) { totalPxls += swatch.getPopulation(); }…
androidanswered Thiago Luiz Domacoski 7,310 -
1
votes1
answer41
viewsA: Data search and comparison
We have a small bug in your code! But I don’t know if that’s what you’d like to report! What happens if the user enters an account that doesn’t exist? He will always show the first! You start the…
-
3
votes4
answers543
viewsA: Variables operating in more than one method
Your mistake is in this excerpt: public void run() { new Calculadora().perguntarValores(); new Calculadora().calcular(); new Calculadora().exibirResultados(); } Here you create an instance to take…
-
3
votes2
answers872
viewsA: How to leave a Alertdialog with rounded edges?
Follow an example: Java: Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));…
-
1
votes0
answers27
viewsQ: Plus.Peopleapi cannot connect
I am developing an application that will create, read and update some documents on Drive. In the NavigationView, I would like to identify the User’s account. The same way it’s done in the Google…
-
2
votes2
answers951
viewsA: How to pass variable by parameter created in Enum in Java?
Let’s go there are two examples: Switch To use the switch it is necessary to create Constants with their values: public static final int AZUL= 1; public static final int VERMELHO= 2; public static…
javaanswered Thiago Luiz Domacoski 7,310