Posts by rsicarelli • 3,086 points
110 posts
-
2
votes3
answers180
viewsA: How to use repeated methods?
Another option, besides those already cited/answered, is to use a practice called custom view. Basically, you create a class that inherits from the type of View that you want to modify and make your…
-
2
votes1
answer119
viewsA: Best way to access Activity components - MVP
Within the MVP standard (Model-View-Presenter), the construction of the object Paciente should be made within your Presenter and its View (be she Activity or Fragment) is responsible only for cede…
-
3
votes2
answers957
viewsA: QR Code reader embedded in my own Activity
You can use the Barcode API of Google itself. It supports the formats: 1D barcodes: EAN-13, EAN-8, UPC-A, UPC-E, Code-39, Code-93, Code-128, ITF, Codabar. 2D barcodes: QR Code, Data Matrix, PDF-417,…
-
0
votes3
answers604
viewsA: High-box text button in Android API < 14
I recommend you use the AppCompatDialogFragment to do this! This class is available within the appcompatv7, and will already do all the work of using the correct theme for your application. To use,…
-
0
votes1
answer135
viewsA: Class import that turns gray
You need to disable the Auto import of your Android Studio. For that reason: 1) Go to Preferences 2) In Publisher > General , select Auto Import: 3) Leave only the first option selected, like…
-
1
votes2
answers117
viewsA: Multiple images inside an Image Button with padding
You can create a <layer-list> with several circles inside, using the attribute dashGap and dashWidht and put as src of your ImageView: <layer-list…
androidanswered rsicarelli 3,086 -
0
votes1
answer42
viewsA: How to recover images from an android device through a date?
You can use the lastModified() class File: File file = new File("seu_path.jpg"); Date dataImagem = new Date(file.lastModified()); Log.i("Data do arquivo @ : "+ dataImagem.toString());…
-
1
votes1
answer39
viewsA: Load and set bitmap asincrona
You can use a AsyntTask for this. Try something similar: class CarregaImagem extends AsyncTask<Integer, Void, Bitmap> { private final WeakReference<ImageView> imageViewReference; private…
-
1
votes3
answers488
viewsA: Keep data from a list when rotating on Android
Besides the answers given, a great option is the library IcePick. Through annotations, you can easily define which variables you want to keep the state by eliminating the Boilerplate to save all…
androidanswered rsicarelli 3,086 -
3
votes2
answers103
viewsA: String deserialization
The problem is that you’re putting one objeto within a array. In view of the fact that, drivers.get(0) returns a driver object, your code needs to look something like: Gson gson = new Gson(); String…
-
4
votes1
answer137
viewsA: How do I apply monetary mask to my listview?
You can use the NumberFormat of Java itself for this, through the method getCurrencyInstance(Locale). In Locale, you need to pass in what currency format according to your location. In the case for…
-
1
votes1
answer256
viewsA: Layout Hierarchy
First, let’s understand what’s going on with your layout. When you use the RelativeLayout, you’re putting your components all together, and then telling them how to behave (via attributes like…
-
4
votes4
answers334
viewsA: Advantages of Inner Class
The use of Inner Class makes total sense in several cases. If no other class needs/uses it, make it private. If it does not require exclusive access from other members of other classes, make it…
-
0
votes2
answers374
viewsA: Error while subtracting with no value fields (Android)
When developing functionalities in this way, we need to pay attention to the input of information, mainly ensuring whether it is valid or not. In your case, I see two big points that could cause…
-
1
votes1
answer84
viewsA: Show an application A within the Fragment of another application B
No phones "rootados": Unfortunately, it is not possible to display an application within your application without your phone having the permission of Administrator (root), because you can only…
-
3
votes1
answer416
viewsA: Keep screen on v4.1.x
A very common practice in Android development is to use PowerManager.WakeLock to do such a task. However, this is not the ideal and most reliable option, as you will need to add an extra permission…
androidanswered rsicarelli 3,086 -
3
votes2
answers75
viewsA: How can I share an image via Mail, Bluetooth, etc?
The problem is that you are invoking the setDrawingCacheEnabled() but you’re not caching your image. Try something similar: imageView.setDrawingCacheEnabled(true);…
-
3
votes1
answer118
viewsA: Android Protection Reverse Engineering Client-Server
You can use the Protocol Buffers, of Google itself. Protocol Buffers is neutral to any language, platform, and has a very good way of serializing objects. They are flexible, efficient and have an…
-
1
votes1
answer178
viewsA: Okhttp only works on Lollipop
The problem is that you failed to add the Okio, another library that the OkHttp needs to work, according to official documentation: You’ll also need Okio, which Okhttp uses for fast I/O and…
-
2
votes1
answer1518
viewsA: how to simply place an icon in actionBar?
You can use the Toolbar for that reason. To Toolbar replace the ActionBar Android standard and with it is much easier to work. First, you must configure your application theme to support Toolbar,…
-
0
votes3
answers1110
viewsA: I have 5 threads running in parallel. How do I know when they’re all gone?
You can use the method getAllStackTraces() of one’s own class Thread for that reason: Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); To convert to an array of Threads: Thread[]…
-
1
votes1
answer1233
viewsA: How to adjust screen according to Android virtual keyboard?
Within your AndroidManifest.xml add the following property inside the <activity> you want to add this attribute: android:windowSoftInputMode="adjustResize"…
-
1
votes3
answers552
viewsA: How to convert pixel to dp?
Try something like that: public static int converteDpParaPx(Context context, int dps) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); return…
-
1
votes3
answers2000
viewsA: How do I get a Facebook profile picture?
You can recover the URL of the user’s photo through your id: private String recuperaFotoPerfilFacebook(String userID) throws MalformedURLException { Uri.Builder builder =…
-
0
votes1
answer90
viewsA: android.widget.Framelayout$Layoutparams cannot be cast to android.support.v4.widget.Drawerlayout$Layoutparams
Instead of passing your mDrawerList as a parameter, try to pass a Gravity: mDrawerLayout.closeDrawer(GravityCompat.START); Or, simply use closeDrawers(): mDrawerLayout.closeDrawers();…
androidanswered rsicarelli 3,086 -
1
votes1
answer4019
viewsA: Setting width and height of an Imageview
To change parameters of a View (anyone who inherits it), you can use the native class LayoutParams. In your case, to change the size of your ImageView dynamically, try something similar: ImageView…
androidanswered rsicarelli 3,086 -
2
votes1
answer51
viewsA: How to list all Browsers installed on Android?
It is impossible to know/determine which applications are of the Browser type, for the simple reason that there is no identifier informing this for Android. It is also very risky for you to search…
-
3
votes2
answers336
viewsA: Multi-device layout display problem
You are making some mistakes in your layout: 1) When you need to put fixed size in components on android, you should use the measure dp instead of pt (or, the most famous, px). I mean, instead of…
-
0
votes3
answers931
viewsA: Images getImageUrl()
You can use the Picasso. Picasso is a very popular and used library in Android development that solves all the problem of loading and processing images for you and also simplifies the display of…
androidanswered rsicarelli 3,086 -
1
votes2
answers2331
viewsA: Edit the name of Aplicationid in android Studio
A good tip (quick and easy) is to create a new package and move everything to this new package. Redo the whole of the rename of your package, leave as was (com.examplo). Create a new package, as you…
androidanswered rsicarelli 3,086 -
1
votes1
answer2489
viewsA: Real-time monitoring with location
First, you need to analyze whether you need real-time information or whether there might be an update time. If you need your information in real time, you can use the Firebase for this. With the…
-
1
votes1
answer158
viewsA: Communication between Fragmentes and Eventbus
This behavior is normal of yours FragmentStatePagerAdapter. He will always have the instance of his View visible + previous + next. In your case, when you are at first, it only possessed in memory…
androidanswered rsicarelli 3,086 -
10
votes6
answers8471
viewsA: Do not open keyboard automatically when on screen with Edittext
You need to add android:windowSoftInputMode="stateHidden" within your AndroidManifest.xml: <activity android:name=".SuaActivity" android:windowSoftInputMode="stateHidden"/> This flag will hide…
androidanswered rsicarelli 3,086 -
1
votes1
answer398
viewsA: Attach a photo to the email
You’re gonna need a Intent putting the Uri of your photo as EXTRA_STREAM. Try something similar: private void enviaEmail(Uri uriDaSuaFoto) { Intent emailIntent = new…
androidanswered rsicarelli 3,086 -
0
votes2
answers971
viewsA: Problems using the Edittext.setError() method
Your code is correct, you just need to add one "phocus" to the EditText who is trying to assign the setError(). Try something similar: if (usuario.getText().toString().length() == 0) { campoComFoco…
androidanswered rsicarelli 3,086 -
4
votes1
answer376
viewsA: How to ignore the accents in Listview on Android?
If you are in API 9 or higher, you can use a simple method with Normalizer and a REGEX to remove all accents. If not, you will need to create a Map with the accents and change them. Try something…
-
9
votes2
answers1042
viewsA: How to make the use instructions screen when starting an app
This presentation is called Tour, User Onboarding or App Intro. I recommend using the library Appintro, already follows all aspects for a great introduction to your app. You can find a example…
androidanswered rsicarelli 3,086 -
4
votes2
answers96
viewsA: Error generating custom Listview
You forgot to instantiate your LayoutInflater. Inside of your builder BluetoothAdapter(), try something similar: public BluetoothAdapter(Context ctx, List<BluetoothDevice> dispositivos) {…
-
2
votes3
answers101
viewsA: Is it possible to put Abels in Listview?
You will need a Adapter who inherits from BaseAdapter. This will enable you to Adapter accept other objects. For this, you will need to create a template Pais which has as its attribute id and the…
-
3
votes1
answer265
viewsA: How to download PDF with the url in sdcard? Android
You can use the class DownloadManager from Android itself. It will already do all the work for you (including notifications with progress and success/failure): String url = "http://suaurl.com.br/";…
-
0
votes1
answer260
viewsA: Send Google maps address of a messaging app to your mobile?
You can use the API Smsmanager: btnSendSMS.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { enviarSMS("+551199999999", "Testando"); } }); ... //Enviando a mensagem…
-
2
votes2
answers355
viewsA: Change Status Bar to transparent in a Fragment within an Activity
You can change through the method setStatusBarColor(): context.getWindow().setStatusBarColor(Color.TRANSPARENT); Remember that this function is only available from API 21 (Lollipop), then make a…
-
4
votes1
answer2999
viewsA: Create button via code
First you need to define where you will put your button (a container, for example): <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"…
-
1
votes1
answer3030
viewsA: How to insert a library into a project in Android Studio?
First, perform your Android Studio with permissions of administrador. After that, navigate to the build.gradle at the root of your project and add the line: buildscript { repositories {…
-
1
votes1
answer41
viewsA: Google maps v2 is returning "INVALID_REQUEST"
According to the standard of Encode of HTML characters, %22 means, deciphered, ". That is, your URL is being interpreted as:…
androidanswered rsicarelli 3,086 -
1
votes2
answers1571
viewsA: How to use Android Scrollview via Java code?
To use your layout in . xml, you need to inflate it into a View: LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewExemplo =…
-
3
votes1
answer1665
viewsA: How to pass information from listview to a new Activity?
First, if you intend to pass Objects you created between Activities, you need to implement it as Parcelable or Serializable. Implement your class as Parcelable or Serializable, means that you can…
-
2
votes1
answer212
viewsA: Notification fixed at the top
Just add the flag Notification.FLAG_ONGOING_EVENT in his Notification. suaNotificacao.flags = Notification.FLAG_ONGOING_EVENT; If you want to add more than one flag to your Notification, utilize |=…
-
2
votes1
answer177
viewsA: Pre-development questions about android app with data synchronization
For the use of the internal database, I suggest you use the SQLite. Android has native support for it, and is super quiet to implement. For cloud synchronization, if you don’t want to develop an API…
-
6
votes1
answer767
viewsQ: How to make a smooth animation in Progressbar?
I’m trying to implement a smooth animation in my ProgressBar, but, if I increase the duration time, the animation stops being "smooth". Example with 5 seconds: Example with 30 seconds: ProgressBar…