Posts

How createa new activity

Image
Creating a new activity For create a new activity into a exist project follow the next steps. Step 1.  Create a Empty activity Select the layout folder, select "New", next select "Activity", next select "Empty Activity".  This action will be create all necesary for work on a new activity. This will do next: Add  the activity into AndroidManifest. Create a new class for activity Create a new activity layout Important: It don't will create an event for you activity, for do it you need create an event for use the activity. Step 1.  Set name for activity You will see this windows after create a new activity. You have to set activity name and the other fields are optionals. Step 2.  Use The activity will be crated and you can use it.

How allow download and show images from url

How allow download and show images from url This manual will show you how to allow and show images from a url path. I had this problem and I solved in the following way, there is a library called Picasso, I will leave link for install. Just you have to use this line into your logical for load imagen and the library does the rest. 1.-Include library into dependencies and sync Gradle. implementation 'com.squareup.picasso:picasso:2.5.2' 2.- Include library import com.squareup.picasso.Picasso; Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView); In this example the url is passed like parameter by string and the second parĂ¡meter is a "imageView" object. Link for Picasso The disaventages is that you will need internet connetions for it works. Resources: http://square.github.io/picasso/

How raneme packname

Image
How rename packname If you need rename your packname you can follow next steps. 1.- Disable "Compact Middle Packages". 2.-Rename Folder Select folder you want chage, rigth click and the folder and select "Refactor" and "Rename" and will apear a warning window, select  "Rename packge" option. 3.- Apling changes Will appear a Refactor preview you should select "Do refactor" option for apply the change. You can repeat this step by folder that you need change. 4- Change Greadle Search file called "build.gradle" and change applitionId android {     compileSdkVersion 27     defaultConfig {         applicationId "com.example.hello"         minSdkVersion 22         targetSdkVersion 26         versionCode 1000         versionName "1.0.1"         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"         // Enabling mul

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();