Posts by ramaral • 44,197 points
1,060 posts
-
9
votes1
answer420
viewsQ: How can I "postpone" the startup of a property?
There are situations where the property initialization is not possible to be made in the declaration, its value is only known later. An example of this is, on Android, references to views of a…
-
1
votes1
answer62
viewsA: How to access another application with Sqlcipher database by passing the password in Content Provider?
As far as I know that’s not possible. What you should do is set permissions that applications that want to access the provider should have. In the provider’s application Androidmanifest declare one…
-
0
votes1
answer64
viewsA: Swipe Refresh in api 15
You can use the Swiperefreshlayout in version 9 and later if using the Support Libraries. In the xml use: android.support.v4.widget.SwipeRefreshLayout Support Library Settings.…
-
3
votes1
answer464
viewsA: Error returns when trying to start some threads in a list
Error happens because a Thread cannot be restarted. You must recall the method addThreads() for them to be recreated. Add to the method threads.Clear(); for the list to be cleaned. You have to…
-
0
votes3
answers303
viewsA: When I roll my listview I miss checkboxes marked
Each time Listview needs to render an item/line calls the method getView() of Adapter. In the implementation of this method the inflate of a new layout and its views are assigned their respective…
-
0
votes1
answer166
viewsA: Bound Service using Intentservice
Ibinder should not be used with Intentservice. The purpose of Intentservice is to perform only one task. It is destroyed soon after the method onHandleIntent() break up. I find it strange that the…
-
4
votes1
answer330
viewsA: Jobscheduler to run every x hours
Jobscheduler requires API 21+. An alternative that works in all versions is the Gcmnetworkmanager. It uses Jobscheduler in versions 21+ and in lower versions uses its own implementation. To use it,…
-
0
votes2
answers536
viewsA: Webview updating URL page when rotating the screen
This is because when the device runs Activity where Webview is destroyed and recreated, making the method oncreate() be called. Do the override of the method onSaveInstanceState and save the Url…
-
1
votes1
answer213
viewsA: How to prevent onItemSelected from being called when using setSelection?
It was expected that this would not happen, since the spnSituacaoItem.setSelection() are before the assignment(setOnItemSelectedListener()) of the Onitemselectedlistener. The reason why it happens…
-
3
votes2
answers151
viewsA: GPS still on after closing Activity
Whatever method you use to track the location of the device should initiate it in the method onResume()/onStart() and finish it in the method onPause()/onStop(). If you are using Fusedlocationclient…
-
0
votes3
answers150
viewsA: Problems using string for resources
At the time you are using the method getString() the context is null. Note that you are instantiating the Questions class at the time of the declaration. public class MainActivity extends…
-
2
votes1
answer3095
viewsA: Emulator without internet connection
I think this is a problem of the version of Android Emulator you are using. I say this because I came across this problem and it disappeared when I upgraded to version 26.1.2. To check which version…
-
2
votes1
answer791
viewsA: It is possible to last a variable in Strings.xml
I don’t know if that’s exactly what you’re thinking, but you can do something like this: Resources res = getResources(); String text = res.getString(R.string.nome, username); textView.setText(text);…
-
2
votes1
answer403
viewsA: Recovering Edittext text in Alertdialog
Use the Dialog object passed to the method onClick() of the Dialoginterface.Onclicklistener to obtain the reference to Edittext: dialogs.setPositiveButton("Sim", new…
-
1
votes2
answers936
viewsA: Open map at current user position
First you need to get the user’s location using Fusedlocationproviderclient. See how in this reply. The second step is to use the method moveCamera(), normally in the method onMapReady(), to…
-
2
votes2
answers1275
viewsA: How do I get the back button to close Activity without going back to the previous one (finish the app)?
In Activity login, right after the line you have startActivity() place finish();. This will close the Activity login by making sure that clicking the back does not return to it and the application…
-
3
votes1
answer4540
viewsA: Substitute for the Progressdialog
I was wondering which component could be his replacement (...). The suggested replacement is Progressbar. Both, Progressdialog and Progressbar, exist since the initial version of Android. I was…
-
1
votes1
answer15
viewsA: listDataHeader for a String
listDataHeader was initialized so: listDataHeader = Arrays.asList(headers); as headers is a String array String[] headers = res.getStringArray(R.array.nav_drawer_labels); therefore, the items of…
-
2
votes1
answer3044
viewsA: How to get the context in a Fragment?
In a Fragment the context can be obtained through getActivity() Eventually getActivity() can return null. To ensure you get a valid context get it in the method onAttach() and keep it in a field so…
-
2
votes1
answer118
viewsA: How to put € symbol on Datagridview
Use the property Defaultcellstyle to define the style to be applied to cells in a given column. In this case you must use the property Format: dataGridView3.Columns[1].DefaultCellStyle.Format =…
-
5
votes2
answers4919
viewsA: How to change the color of the Statusbar?
Statusbar color is by default the color assigned to colorPrimaryDark. In versions below 21 it is only possible to change it by changing the colorPrimaryDark. Which means that every component that…
-
0
votes1
answer46
viewsA: Problems with Objectanimator
Jump is due to variable value height not be the value of the position y where Imageview is located. When starting the animation the image "jumps" from its position to the position height and only…
-
1
votes1
answer47
viewsA: Error using date type on android
dtis a String. It was declared like this: String dt = "2017-01-04"; What you should use is the Date object returned by: sdf.parse(dt); Something like that: String dt = "2017-01-04"; Date data =…
-
8
votes1
answer149
viewsA: Add() method does not add Timespan to Datetime
Datetime is a structure(struct) that represents an instant in time. The representation/value of a given instant in time does not change, it is that and not another. To ensure that this is so the…
-
1
votes1
answer364
viewsA: How to grab the value stored in a column using Cursor?
For each type of data a table column stores the interface implementation Cursor provides a method to obtain its value. To get the value stored in a string type column you must use the method…
-
18
votes1
answer489
viewsQ: Why does the compiler require local variables to be initialized and fields not?
The question Why a variable with default value is usually declared? addresses the question of whether or not to initialize a variable before using it. However this option becomes mandatory when it…
-
1
votes2
answers237
viewsA: Radiogroup in Listview does not maintain selection after scroll
The Evaluator class must have a field and respective get/set methods to store which Radiobutton is sectioned. private int selectedRadioButtonId; public int getSelectedRadioButtonId(){ return…
-
2
votes2
answers245
viewsA: Cannot Resolve Method isChecked()
This method does not exist in the Radiogroup class. The Radiobutton that was selected is the one whose id is in checkedId. That switch already identifies which is. If you want to keep in flag will…
-
1
votes1
answer715
viewsA: onClick Recyclerview Android
Don’t think because you don’t have any Clicklistener type attributes declared in the Textitemviewholder class. Two possible solutions: Make the Textitemviewholder class one Inner class…
-
6
votes2
answers227
viewsA: How to convert byte to Boolean[8] and convert back?
I believe that there will be various ways of doing this. What I can think of now is: Use expression (b & (1 << i)) != 0 to check whether the bit in position i byte is "set" and store the…
-
6
votes2
answers522
viewsA: Webview links do not work
In the method shouldOverrideUrlLoading() instead of returning true return false. true indicates that the application will handle the URL (for example, launching an Intent with the link to be viewed…
-
0
votes1
answer385
viewsA: How to toggle debug directory view for release, or vice versa?
Follow the following steps: 1) In the lower left corner of the IDE click the Build Variants tab. 2) In the window that opens, in the Build Variant column, choose release…
android-studioanswered ramaral 44,197 -
2
votes1
answer265
viewsA: Buttons (Action) in the notification. How to know which one was clicked?
Another thing that I didn’t intend but happen, is that the user is redirected to an Activity, and I didn’t want that. For this purpose the Pendingintent used in the method setContentIntent() should…
-
1
votes1
answer115
viewsA: Android notifications are not released
Instead of a Broadcastreceiver use an Intentservice to launch the notification. public class CriarNotificacao extends IntentService { private PowerManager.WakeLock wakeLock; public…
-
1
votes2
answers58
viewsA: How do I make an operation run moments after I have clicked a button?
Edit after question editing. If what you want is the first notification to be made with a delay the same as the following handler.post(runnable); for handler.postDelayed(runnable, 1000 *…
-
6
votes2
answers986
viewsA: What is the purpose of setTag and getTag methods in View?
What purpose of setTag() and getTag methods()? The objective of setTag() is to allow to store any object. This object can then be recovered with getTag(). When should they be used? When you want to…
-
11
votes3
answers361
viewsA: Is it correct to call a method, and pass your null parameters?
If you want to execute the code {faz alguma coisa} when the menu option is either clicked by the user or directly by a call from his code, the "most correct" is to create a method with that code:…
-
1
votes2
answers415
viewsA: Access Sqlite database in another Activity
It is not a rule, but the usual and the most "simple" is to do what you did: a class inherited from Sqliteopenhelper and eventually another with methods to access/manipulate the data in the…
-
2
votes1
answer7071
viewsA: Why is the error "This view is not constrained ..." in Constraintlayout?
This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints. That notice indicates that views declare no restrictions(constraints) sufficient…
-
0
votes2
answers6645
viewsA: What is the function of wrap_content?
Its function is to inform that the view or layout should be sized enough to show all its contents, including any paddind defined. How it works. The layout design is processed into two passages:…
-
1
votes2
answers182
viewsA: How to create a Layout bitmap keeping the dimensions equal regardless of the screen density?
The number of pixels that Bitmap will have is a function of the pixel density of the device screen. Thus, in order for the print size to be independent of density, you must resize the Bitmap…
-
2
votes2
answers245
viewsA: Error using a Static final String to build an SQL query
The problem is not in the use of constants but in the query syntax, which is wrong. Between SELECT and FROM you need to enter the name of the columns that select should contain or * if you want it…
-
1
votes1
answer255
viewsA: After changing Navigation Drawer icon it no longer opens
It doesn’t do what you expect it to do. ActionBarDrawerToggle#setHomeAsUpIndicator() to indicate which Drawable to use when Drawer Indicator is disabled. It is shown when setDrawerIndicatorEnabled()…
-
1
votes2
answers665
viewsA: How to send calculation performed in a Service for Activity?
If you want to perform the calculation asynchronously use an Intentservice and use the Resultreceiver class (as suggested by @Rudda Beltrao) to receive the result. Example of an Intentservice to…
-
1
votes2
answers700
viewsA: How to install/run a signed app to view the error log?
Install via Androidstudio. In the menu of Android Studio choose build -> Edit Build Types.... In the window shown select tab Signing and click on the sign +. Fill in the fields on the right side.…
-
3
votes4
answers16860
viewsA: How to get the current location of android device?
With the version 11.0.0 of Google Play services SDK obtaining the user’s location has become even simpler. Now it is no longer necessary to manually manage the connection to the Google Play service…
-
0
votes1
answer31
viewsA: Pop-up menu does not check radio Buttons
The problem is that every time you click the button btntimer a new Popupmenu is created, causing the previous one to be lost as well as the Radiobutton "checked". You must create Popupmenu outside…
-
2
votes1
answer92
viewsA: How can I avoid repeating code?
Whenever you verify that you are repeating code the first approach is to isolate it in a method. The method should have parameters to receive what is different: private void postCatLivro(String url,…
-
3
votes1
answer807
viewsA: How to hide keyboard when leaving Edittext?
If you want to hide the keyboard when you click that area set an Onclicklistener for it and use Inputmethodmanager to hide the keyboard. Put into the method onCreateView after "inflating" the…
-
2
votes1
answer70
viewsA: How to put only the class name on the combobox?
By default is presented what is returned by the method ToString() which, if not overwritten, returns the full name(the Qualified name) class . Overwrite the method ToString(), of the class you are…