android set image as contact icon/wallpaper -
I have written my own imageviewer and now I have the set as functionality in the Android country . image viewer. Now this is possible because Facebook has it. I have attached a screenshot to make myself more clear PS I want to give a more detailed description of what happened wrong. After selecting the "Contact icon" in the menu, a list of my contacts appears, when I select a contact, the application stops the force. If I choose "home / lock screen wallpaper" then it opens my phone gallery. Here is my code snippet: I have also added the result permissions for my manifest and I am able to write my image in the phone's SD card. : from Utils.java
Bitmap icon = mbitmap; Intent setAs = new intent (Intent.ACTION_ATTACH_DATA); SetAs.setType ("image / jpg"); BytereonOperputsTream Bytes = New ByteOrthroughs (); Icon.compress (bitmap compoforat.jpg, 100, bytes); File f = new file (environment .getExternalStorage directory () + file. Separator + "/my_tmp_file.jpg"); Try {F.createNewFile (); FileOutputStream fo = New FileOutputStream (f); Fo.write (bytes.toByteArray ()); } Hold (IOException e) {e.printStackTrace (); } SetAs.putExtra (Intent.EXTRA_STREAM, Uri.parse ("File: ///sdcard/my_tmp_file.jpg")); Initial Activity (Intent.createChooser (setAs, "Set as Image"));
// is called when click on "Set as". Private stationary Boolean on STAsolved (menu incakara on invoke, last activity activity) {onInvoke.run (new menu callback) {public zero-zero (Yuri U, IIIM image) {if (U == blank} image == empty) {Return;} intent to intent = uTil.CreateCatAsIntent (image); activity.art activity (intent .createchor (intent, activity.gate text) (R. string .seetmage)));}}); Back true; }
// returns a purpose that is used for the menu item as "set". Making public static intentionSetset content (IImage image) {Uri U = image. Full Size Image Yuri (); Intention = Intention = Intent (Intent.ACTION_ATTACH_DATA); Intent.setDataAndType (u, image.getMimeType ()); Intent.putExtra ("mimeType", image.getMimeType ()); Intent to return; }
Comments
Post a Comment