Posts

Showing posts from March, 2019

Retriving Android API version by code

I will show you how get Android API version by code. You can use this comparation.  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // Example compare with Android Oreo  } References. https://stackoverflow.com/questions/3423754/retrieving-android-api-version-programmatically https://developer.android.com/training/notify-user/channels#java https://developer.android.com/reference/android/os/Build.VERSION

Understand the Activity Lifecycle

Image
How Activity works  This diagram show how to Activity lifecycle works.  onCreate() You must implement this callback, which fires when the system first creates the activity.  Bibliographic reference https://developer.android.com/guide/components/activities/activity-lifecycle

Add image from URL

How to add a image into menu from url I will show how to add a image from url like a Drawable object  You will need this references. In this case we will use this method  import android.graphics.drawable.Drawable; import android.graphics.drawable.BitmapDrawable; import java.net.URL; import java.net.HttpURLConnection; import android.graphics.BitmapFactory.Options; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; You could be need add this policy into main activity. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();         StrictMode.setThreadPolicy(policy); You can use this method into your class     public static Drawable getImageByteUrl(Context context,String url)     {         Drawable image = null;         try         {             URL imageUrl = new URL(url);             HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();             conn.connect();          

Android versions

Image
Android version history This is a history version of Android Updated 04-March-2019