set Title when encode Web URL QR code android - android

I want to set the title when i encode a Web URL. I Use QRCodeEncoder class to encode the contents. I don't find anything to set title for the web URL. I use below code to encode the input text field content and generate image.
// check validation for input string
if (URLUtil.isHttpUrl(inputWebURL)) {
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(
inputWebURL, null, Contents.Type.TEXT,
BarcodeFormat.QR_CODE.toString(), smallerDimension);
try {
bitmapCreatedImage = qrCodeEncoder.encodeAsBitmap();
ImageView myImage = (ImageView) findViewById(R.id.imageViewCreatedWebUrl);
myImage.setImageBitmap(bitmapCreatedImage);
} catch (WriterException e) {
e.printStackTrace();
}
}
How I set Title for the Web URL QR encoding?
Thanks.

Related

Android. Can't decode Bitmap from stream

I have URL to PNG image file.
I want to get this image file and set it as a source for an ImageView.
My code:
URL iconURL = null;
try {
iconURL = new URL("https://maps.gstatic.com/mapfiles/place_api/icons/worship_general-71.png");
} catch (MalformedURLException e) {
e.printStackTrace();
}
Bitmap icon = null;
try {
icon = BitmapFactory.decodeStream(iconURL.openConnection().getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
myImageView.setImageBitmap(icon);
If I place a breakpoint into the line with decodeStream() the app stops and I see the following:
If I run the app in regular mode, it just stops!
Can someone explain what is wrong here and how to do it correctly?
Thanks.
If you just want to show the image on your ImageView then you can use Picasso Library.
Put below dependency in build.gradle file
'com.squareup.picasso:picasso:2.71828'
And use below java code for loading your image from URL to your ImageView
Picasso.get()
.load(url)
.into(imageView);

Image is cropped when using jsoup library

Am trying to download an image using jsoup library and set it to image view but the downloaded image is cropped automatically. i don't know if it is the library or something else. Here is my code, Any one to help me please?
try {
// Connect to the web site
Document documentImage1 = Jsoup.connect(url).get();
// Using Elements to get the class data
Element img = documentImage1.select("div[class=media-img imgflare--river] img[src]").first();
// Locate the src attribute
String imgSrcImage1 = img.attr("src");
// Download image from URL
InputStream inputImage1 = new java.net.URL(imgSrcImage1).openStream();
// Decode Bitmap
image1 = BitmapFactory.decodeStream(inputImage1);
} catch (IOException e) {
e.printStackTrace();
}

How to add an audio file to an image in Android

I want to add an audio file to an image. So when someone gets that image he can extract the sound from it. I think we can add additional data to image header. But I don't know how to do that sort of header processing in Android. Can you please guide me...
Using the below code you can add a small comment to the JPEG header in Android. It's only for JPEG.
final static String EXIF_TAG = "UserComment";
public static boolean setComment(String imagePath, String comment) {
try {
ExifInterface exif = new ExifInterface(imagePath);
exif.setAttribute(EXIF_TAG, comment);
exif.saveAttributes();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
But the problem is you can't put a audio file there because the data stream is way too big to fit in to the header.

How to display rectangle thumbnails for video in android

Hi all i want to display video thumbnail with rectangle shape as in given link .I have used some code and now video is displaying in thumbnail but not with rectangle as display in given link.So please suggest me, is this is possible in android or not .If possible then how..Thanks..
http://lh3.ggpht.com/_xBHTh_QdoYY/S81nyg57zsI/AAAAAAAAA2A/knYE08lHypU/video3e312550f115%5B15%5D.jpg
Use this code to get the thumbnails-
Bitmap _bitmap = null;
thumbnail = new ImageView(mContext);
thumbnail.setScaleType(ImageView.ScaleType.CENTER_CROP);
try {
String path = "SOME PATH GOES HERE...";
_bitmap = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Video.Thumbnails.MICRO_KIND);
thumbnail.setImageBitmap(_bitmap);
} catch (Exception e) {
thumbnail.setBackgroundResource(R.drawable.icon);
e.printStackTrace();
};

Displaying Images parsed from JSOUP in android?

I've been trying to develop an android app that parses through a specific (business's) website, and display the head image of the site on the top, news on the bottom, and have buttons below it that will open a new activity to display the schedule for the business, and any other information about the business. I decided to use JSOUP, which I am very new to, but I can't figure out how it is that I go about displaying images. I tried something like this, but it didn't work:
ImageView image = (ImageView) findViewById(R.id.headImage);
Document doc = Jsoup.connect("http://www.example.com/").get();
Elements divs = doc.select("img");
for (Element div : divs) {
Log.d("web Stuff",div.text());
text.setText(text.getText() + "\n" + div.text());
Element myImage = div;
String url = myImage.absUrl("src");
image.setImageDrawable(Drawable.createFromPath(url));
}
how am I supposed to correctly implement something like this?
I would load the image in a new thread if you want to do it for more than one image.
public void run() {
URL url = new URL(url);
Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
}
when the Thread is finished you can set the image of the imageview.
image.setImageBitmap(bitmap);
Drawable drw =LoadImageFromWebOperations(image_url);
im.setImageDrawable(drw);
private Drawable LoadImageFromWebOperations(String strPhotoUrl)
{
try
{
InputStream is = (InputStream) new URL(strPhotoUrl).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
}catch (Exception e) {
System.out.println("Exc="+e);
return null;
}
}

Categories

Resources