Posts

Showing posts with the label android programming

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 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=(...