Posts by ramaral • 44,197 points
1,060 posts
-
5
votes3
answers876
viewsA: How to repeat a minute-to-minute notification
Create a service that uses Handlerthread to launch notifications periodically. public class NotifyService extends Service { private HandlerThread handlerThread; private Handler handler; //Define o…
-
1
votes1
answer136
viewsA: Mediaplayer does not play existing sound file in Assets folder
The problem is that the start before the player be prepared: mp01.prepareAsync(); mp01.setVolume(1f, 1f); //mp01.setLooping(true); mp01.start(); The method prepareAsync(), being asynchronous,…
-
0
votes3
answers99
viewsA: Custom Listview with Picasso
The reason for the mistakes. First the one to which the error refers: cannot resolve method super(Activit, int, string) super refers to the manufacturer of the inherited class, in this case to an…
-
0
votes2
answers29
viewsA: Inflateexception
The schemas shall be indicated only once and in layout outermost. Retire xmlns:android="http://schemas.android.com/apk/res/android" of the declaration of Fragment. <FrameLayout…
-
4
votes2
answers86
viewsA: Compare Background with Drawable
getDrawable() does not return the background but rather the image assigned by android:src. Instead of getDrawable() use getBackground() if…
-
0
votes4
answers148
viewsA: Background of Imagebuttons
You are trying to use a Drawable as an argument in a method that expects a int. To change the background you must use setBackground() and use getBackground() to get the background of the other…
-
0
votes1
answer118
viewsA: Mock Authentication on the dao
These are different types of tests. The first, using mocks, is a unit test. Its purpose is to test the logic/rule that the method implements. The second is an integration test. The purpose is to…
-
9
votes3
answers813
viewsA: What is the difference between methods for obtaining a context?
They return different "types" of Context, with lifetimes and access to Resources different. Context is an abstract class, implemented internally by the class Contextimpl. The various "types"…
-
6
votes6
answers422
viewsA: How to "call" this correctly?
What is the correct way to write this last THIS? (for example 2)?? Short answer: If the Jsonoasynctask class is declared within (Inner class) of Activity(Outer class) and it implements the…
-
1
votes1
answer96
viewsA: what does it mean to clear a Calendar variable?
The method clear() places all Calendar fields and their value(time value) as "undefined". This implies that the method isSet() any field returns false. The "undefined" value is a detail of each…
-
0
votes1
answer50
viewsA: Stackoverflowerror when using a method
In this case the error is due to one method calling another which in turn calls the first. This causes a loop infinity, eventually resulting in an error of Stackoverflowerror. Observe the following…
-
2
votes1
answer137
viewsA: Buttons added underneath Reciclerview do not appear
Can’t use android:layout_height="wrap_content", in a Recyclerview or Listview, when the number of items exceeds the screen size. wrap_content means "make me big enough to present all my content".…
-
2
votes2
answers483
viewsA: Dynamically change the layout of Buttons
If I understand correctly what you want is that when only one of the buttons is visible it should occupy the full width of Linearlayout. So they are declared with…
-
4
votes2
answers477
viewsA: Validation of Textbox
Record this method as Handler Keypress event for all Textbox: textBox1.KeyPress += txtTempoAcel1_KeyPress; textBox2.KeyPress += txtTempoAcel1_KeyPress; textBox3.KeyPress += txtTempoAcel1_KeyPress;…
-
5
votes1
answer153
viewsA: Map opens before picking up the GPS position
The order of execution of methods is the order in which they are called and not the order in which they are declared. The order as you’re doing is ask to be created the map and then ask to be…
-
0
votes1
answer197
viewsA: Preferenceactivity#findPreference() returns null
This line of logcat Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void…
-
0
votes2
answers90
viewsA: Public with 2 variables does not return value
The second method does not "work" because it uses attributes Calculo_Mehta.resistencia_concreto and Calculo_Mehta.massa_especifica_sss_brita, of the class Calculo_mehta, which are only initialized…
-
10
votes2
answers213
viewsA: Do I need to assign null to a variable after use?
The answer is no, it has no effect on performance. If the idea is to release memory, it won’t have any consequence either, it will only be released when the GC determines it’s the best time for it.…
-
6
votes1
answer2545
viewsA: What’s the difference between a Toolbar and an action bar?
These are different things that Toolbar can be used for the same purpose of Actionbar: providing a App bar. These are the main characteristics of each: Action Bar It’s a special and dedicated kind…
-
4
votes2
answers1212
viewsA: Manipulating an Object class
One possible implementation, for private attributes and primitive types, will be: public class Fmt { public static String getAtributos(Object obj){ /*Esse método tem a função de me trazer os nomes…
-
1
votes2
answers498
viewsA: How can I easily make application location permission?
I don’t understand what the variable MY_PERMISSIONS_REQUEST_READ_CONTACTS is for. Permission request is made with a call to the method ActivityCompat.requestPermissions(). The response is then…
-
4
votes4
answers398
viewsA: Use of self-reference
In the shown example there is none, both refer to the field nome. However, there are situations where this does not happen. See the case of this example: public void setNome(String nome){ this.nome…
-
4
votes1
answer1577
viewsA: How to update Recyclerview simply and efficiently?
In Support Library Review 24.2.0, one of the updates was the addition of the class Diffutil. It makes it possible to calculate the difference between two collections and obtain an object of the type…
-
4
votes1
answer1577
viewsQ: How to update Recyclerview simply and efficiently?
The most efficient way I know to update a Recyclerview is to resort to Adapter methods notifyItemMoved notifyItemRangeChanged notifyItemRangeInserted notifyItemRangeRemoved They, as opposed to…
-
4
votes1
answer477
viewsA: Read another variable in Activity that is updated in Mainactivity
That’s not the best approach. If you have an operation (function) that is executed periodically and the result you want to obtain in more than one location of your application, do not do it in an…
-
4
votes2
answers404
viewsA: What is the difference between Alarmclock and Alarmmanager?
Classes have different purposes: Alarmclock provides a set of constants whose function is to facilitate the creation of a Intent to launch/control an application, existing on the device, that…
-
10
votes1
answer152
viewsQ: Sealed class, with private constructor, versus Static class
When "studying" this class, I checked that it is sealed and has the private builder: public sealed class Interaction { /// <remarks> /// CA1053: Static holder types should not have public…
-
2
votes3
answers96
views -
3
votes3
answers96
views -
2
votes3
answers1031
viewsA: How to insert markers (Marker) into a map in another Fragment?
The way to solve this depends on how you have structured your code. One of the approaches used is Activity managing the two Fragments, making them intermediate between them. Thus, when a Fragment…
-
6
votes3
answers2170
viewsA: How to compare two List and delete repeated fields?
If what you want are the elements of the list 2 that do not exist in the list 1 use the method Except: var notInList1 = lista2.Except(lista1).ToList(); Example: lista 1 => 1, 2, 3, 4 lista 2…
-
4
votes1
answer247
viewsA: How does the Dependency Property (Dependencyproperty) "work"?
So that a property of a Usercontrol(Dependencyobject) can be used in XAML and thus be accessed/calculated by means other than the traditional "get" and "set", such as themes, Binding, animations,…
-
5
votes2
answers227
viewsA: Changing opacity of one form through another
The purpose of a Dialog is to get an answer from the user. User responds by choosing one of the buttons available on it. The method Showdialog() returns a value of type Dialogresult the purpose of…
-
1
votes1
answer112
viewsA: How to change the state of a Togglebutton in java?
Can indicate the status of checked/unchecked of Togglebutton, via java, using the method setChecked(). The state enabled/disabled is indicated by the method setEnabled(). Both methods receive one…
-
0
votes2
answers103
viewsA: Open an Activity with onMarkerClick
I suppose "Point A" and "Point B" are brand titles. If so, use the method getTitle() before making the verification. @Override public boolean onMarkerClick (final Marker marker){ if…
-
1
votes2
answers160
viewsA: How do I resolve the distortion that occurs when I switch from Portrait to Landscape?
Yes, it’s possible, using configuration qualifiers, which allow you to control how the system selects alternative features based on the screen features of the current device. Configuration…
-
7
votes1
answer174
viewsA: Delete function of my table
This is a syntax error, the *is the most. The syntax of DELETE is: DELETE FROM table_name WHERE some_column=some_value; If you want to delete all records do not use the WHERE clause: DELETE FROM…
-
6
votes1
answer280
viewsA: How to make the properties of a User Control accessible in XAML?
To endow a Usercontrol with properties that can be accessed via C# or XAML code should implement them as Dependencyproperty. The implementation consists of the property(CLR Property) you want to…
-
1
votes1
answer95
viewsA: Alternative to obsolete methods onCreateDialog() and showDialog() from Activity?
The indication of obsolete code(deprecated) means that its use should be avoided because it may not be supported in the future and there are currently better/better ways to do so. This does not…
-
1
votes1
answer69
viewsA: java.lang.Classcastexception error when using getSerializable() in API 16
According to this reply on Soen seems to be a bug on Android 4. The suggested way to solve is to do the cast return of the method to Object[] and use the method Arrays.copyOf() to obtain the array…
-
2
votes1
answer67
viewsA: Display Sqlite table field values in the Console
The column id is the type INTEGER. Instead of cursor.getString(indiceColunaId) use cursor.getInt(indiceColunaId) Like Log.i() wait a String has to convert before using: Log.i("Resultado - id: ",…
-
4
votes1
answer573
viewsA: How to open a URL directly from the notification
Should create a Pendingintent as follows: Intent intent= new Intent(Intent.ACTION_VIEW,Uri.parse(A_Sua_URL)); PendingIntent pIntent = PendingIntent.getActivity(MainActivity.this, 0, intent, 0); and…
-
5
votes1
answer35
viewsA: Get the drawable used as a Checkbox image
The method getButtonDrawable() was only introduced in the Checkbox(Compoundbutton) class in version 23 of the API. Has two solutions: Changes the minimum version of the application to…
-
3
votes1
answer226
viewsA: Pass int array 2d to another Activity
The class Intent uses internally a Bundle to store values passed to the method putExtra(). The class offers several versions (overloading/overload) of the method putExtra(), among them one who…
-
4
votes1
answer78
viewsA: Checkboxes in Alertdialog always return the same values
The problem is that the variables sentado and livre refer to the Checkbox of another View and not the Checkbox of another View Alertdialog. alert.setView(inflater.inflate(R.layout.layout_alert,…
-
2
votes1
answer100
viewsA: Know which checkbox is clicked
Use the attribute android:onClick of each Checkbox, in xml, to assign the method that will treat the click. Always use the same name for the method. android:onClick="onCheckboxClicked"/> In java…
-
1
votes1
answer39
viewsA: Error when customizing Infowindowadapter on Google Map?
The method findViewById() is from the Activity object. He finds views that are in the layout passed to the method setContentView(). In the code posted the views markerTitulo and markerSnippet are in…
-
3
votes4
answers1390
viewsA: How to change the dynamically displayed Layout
Cannot change the contents of a <include>, but it is possible to do so in Viewgroup., because you can add and remove views his. Where you want to replace a view on the other place a…
-
1
votes2
answers109
viewsA: How to associate a variable to an ID?
Having the Id of a View is possible to obtain the reference to it using the method findViewById() the layout containing it. So, if the values that are in the array correspond to the Ids declared in…
-
4
votes1
answer139
viewsA: Get meta-data from Androidmanifest
To obtain the information stated in the element meta-date use the field Metadata class Packageiteminfo. If you have the following <meta-data> <meta-data android:name="api_key"…