Posts

How to Create a shortcut on android homescreen

Image
Creating a shortcut on Android home screen is fairly simple.So let's get going. We begin by creating an intent giving the target activity which will open when the shortcut is pressed Intent  target = new Intent(getApplicationContext(), Jumpto. class ); >>then we create another intent that is broadcast across the system : Intent shout = new Intent(); shout.putExtra(Intent. EXTRA_SHORTCUT_INTENT , target); shout.putExtra(Intent. EXTRA_SHORTCUT_NAME , "shortcut" ); shout.putExtra(Intent. EXTRA_SHORTCUT_ICON_RESOURCE , Intent.ShortcutIconResource. fromContext (getApplicationContext(), R.drawable.icon)); shout.setAction( "com.android.launcher.action.INSTALL_SHORTCUT" ); getApplicationContext().sendBroadcast(shout); >>this intent carries all information regarding the shortcut like the name, the icon, and the activity to which it has to jump.when the broadcast is sent the launcher apps receive it and create a shortcut based on the details

How to add new theme in Android studio

Image
To switch between light and dark themes go to     file>settings>appearence>theme and switch between intellij(light) and dracula(dark) or if you want further theming : here are some links you can visit :   http://color-themes.com/?view=index (use jar file) http://www.androidstudiothemes.com/ (use the icls file)

How to add a library to Android Studio

Image
There are 3 different ways to add a library to Android Studio:                     1. In build.gradle                     2. Using a jar file                     3. From android studio 1. Using gradle build         go to build.gradle file in your android studio project:                            most libraries have a compile script provided in thier webpage.like here for picasso:                                                 copy and paste this in build.gradle file and sync                                                   DONE! 2. Using .jar file              Download .jar file from webpage:                                                       create a new directory by right clicking your app folder in project menu and copy this .jar file into the folder            now right click the jar file and select add as library            3.From Android studio            go to Build>edit libraries an

How to load image from URL

Image
To access an image from a URL and then load it in ImageView in android we usually go by using an AsyncTask but there is a library called Picasso that can help us a lot in making the process much much easier. Here is the link to Download Picasso: Download Picasso Here is the link to the official web page: http://square.github.io/picasso/ Adding picasso to Android Studio: simply go to your buld.gradle file in your project and add this compile script at the end and gradle sync  Viola!  Watch this Video to learn How, Easily.... Once you've added the library to your package: A single statement can do the job for you, that being: Picasso . with ( context ). load ( "http://i.imgur.com/DvpvklR.png" ). into ( imageView ); where    "http://i.imgur.com/DvpvklR.png"  must be replaced by your image URL. imageView must be  replaced with your imageView object. for example : ImageView iv=(ImageView)findViewById(R.id.my_imag