Author name: Catalin Prata

Born in Alba Iulia, a beautiful city from Romania. I like hiking and everything related with electronics and IT . Eager to learn and enhance my knowledge in programming languages. My main specialization is on Mobile Applications development (Android and iOS).

Snippets, Solutions

Print Android signing key SHA in code

If you ever want to get the Android SHA (1/256), MD5 or the signing key used to sign your app for example you can use the following snippet. Important! Be aware that you should not print that in a production environment as it might leak sensitive data API 28> (Kotlin) Deprecated (Java) And the converter […]

, , , , , , , ,
Solutions, Tutorial

Make Genymotion point to localhost

I had a lot of fights with this and I think it’s better to write down the solution so I won’t waste my time looking again on google/stackoverflow for it. Maybe this will help you too! Problem You might have a local webservice or something on your machine that needs to be accessed from a

, , , , ,
Snippets, Solutions, Tutorial

Add links to a TextView in Android

Maybe you need to add links to a TextView on Android but you don’t want to use Linkify for some reasons and you also want that link to be opened when the user taps it. Here is a simple solution: yourTextView.setText(Html.fromHtml( “Text with a ” + “<a href=\”http://www.myandroidsolutions.com/\”>link to My Android Solutions</a> “)); // this is

, , , ,
Snippets

Get Android OS Version

If you ever need to get the version of the OS on which your app runs, you can try this out: android.os.Build.VERSION.SDK_INT And you can use it against(for more check this out): android.os.Build.VERSION_CODES.[BASE-KITKAT]   Finally you end up with something like: if(android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.HONEYCOMB){ // do whatever you want here }

, , ,
Snippets, Solutions, Tutorial

Add CardView to Android OS versions below L ()

You might notice the new CardView widget on Android L preview presentation. The view can be used to display text or images and has a nice shadow. You can add that view into your project even if you don’t have the minimum API level to “L”… to do that, follow the steps below: 1.  Edit your gradle.build

, , , ,
Snippets, Solutions

Share image Intent

Whenever you need to share an image from the external storage you can use the startActivity method and an Intent to do that. Doing so, the user will be able to chose whatever app he likes to share the photo. Intent share = new Intent(Intent.ACTION_SEND); share.setType(“image/png”); share.putExtra(Intent.EXTRA_STREAM, Uri.parse(“file:///”+imagePath)); startActivity(Intent.createChooser(share, “Share Image”)); If you don’t append the

, , ,
Privacy Policy

Android Studio / IntelliJ IDEA code regions

If you ever worked with Xcode then you must know the power of “#pragma mark” macro. You could just define regions of code using that and sometimes it helps when you have classes that can get a bit big or if you just want to have a nice structure of your class. Well you can do

, , ,
Snippets, Solutions

Android Gradle & Manifest merge

[Deprecated] This post is now deprecated, the Manifest Merger has changed since my first post. You can find more about this on the android developers site. Manifest file & Gradle If you started using Android Studio and implicitly Gradle, or you just started using Gradle with other IDEs (like Intellij for example), then maybe you

, , ,
Snippets

Clear Fragment back stack

To clear the Fragments back stack of a FragmentManager, you could iterate through all back stack items and call popBackStack() but there is also a more elegant solution. Please see below: // in my case I get the support fragment manager, it should work with the native one too FragmentManager fragmentManager = getSupportFragmentManager(); // this

, ,
Snippets, Solutions

Run code on main/UI thread on android

Android’s UI components are not thread safe so one may need to update Views or other UI components from a secondary thread when returning from an asynchronous database query or a web service call.  If you run the code from a secondary thread you might see that the code crashes almost on each try. Below

, , , ,
Solutions, Tutorial

How to get user location

Nowadays, knowing the location is very important for applications. Even if you want to develop a simple application that returns the coordinates, or you develop different kind of apps that need location and you need to know what is the location of the use,r this tutorial might help you. In order to get your current

, ,
Tools

Android State list generator

Inspired by a post from stackoverflow, I made a simple XML State List generator :), you simply need to fill the inputs with your corresponding drawable names and then press Generate button. For more details regarding android StateList XML please check the official documentation. Android state list generator version 2 is here:  New in android state list generator

, ,
Tutorial

Android and Java sockets – simple messenger

Hello all, as you requested in the previous TCP server-client tutorials, I made a new tutorial on how to create multiple client connections to a single server. I posted the projects on GitHub here for you so I will post here only the main classes and functionality that I consider important to walk through. You

, , , , , , , , ,
Tutorial

Android Studio Graddle, add GooglePlayServices library

Nowadays, everything is in a continuous change, so I don’t know if you heard about this, but the android team moved to a new build system named Gradle.  Also the Android team moved from supporting Eclipse as IDE to Android Studio. The latest, has the Gradle system incorporated so you might want to started migrating to

Scroll to Top