Linearout Null object reference - android

enter image description hereenter image description here
when i change packege na then face this problem
Solution me please any one

Related

How do I set placeholder if the image is null?

I get an image from the server and use Picasso to set it in ImageView. The image can be null so I use let. But when the image is null I get an error. How can I use let to set placeholder if the image is null?
My function:
contactsModel.images?.let { url ->
Picasso.with(itemView.context).load(url)
.placeholder(R.drawable.ic_person_placeholder)
.into(mContactIcon) }
My error:
java.lang.IllegalArgumentException: Path must not be empty.
at com.squareup.picasso.Picasso.load(Picasso.java:297)
Placeholder is used for holding image for the network image. If you want to use the placeholder image when there is a error loading image in the view then kindly use it with error call.
.error(R.drawable.ic_person_placeholder)
as shown in the answer https://futurestud.io/tutorials/picasso-placeholders-errors-and-fading
there are many ways but you can simply check if the URL is empty. then use an image from drawable and add to your image view. use something like this -
if (url.isEmpty()) {
iview.setImageResource(R.drawable.placeholder);
} else{
Picasso.get().load(url).into(iview);
}

Can I get the src URI from an Imageview?

is it possible to get the src Value of an ImageView as URI?
Help would be great
No. By the time the ImageView has the image, the source of that image is long gone.
If you know what image it is in your drawable, you can do something like this.
String path = Uri.parse("android.resource://my.package.name/" + R.drawable.myimage).toString();
More info - https://stackoverflow.com/a/28505621/2197529

Gravatar are not showing up in android app

Here is my code to display profile picture using gravatar.
ParseUser user = mUsers.get(position);
String email = user.getEmail().toLowerCase();
if (email.equals("")) {
holder.userImageView.setImageResource(R.drawable.avatar_empty);
} else {
String hash = MD5Util.md5Hex(email);
String gravatarUrl = "http://www.gravatar.com/avatar/" + hash + "?s=204&d=404";
Picasso.with(mContext).load(gravatarUrl)
.placeholder(R.drawable.avatar_empty)
.into(holder.userImageView);
}
But it is not showing even my profile picture and loads empty drawable.
You used a bunch of fake emails to populate your friend list, if so, gravatar won't be able to find images for those fake emails. So gravatar will return a 404, and your code will use the default "avatar_empty" image in the drawable folder.
A quick way to test to see if gravatar is working is to change the &d=404 to &d=monsterid and create a friend with a fake email "SDFSDSF#DSFSsdfsFSFSssf.com"
That friend will have an gravatar cartoon image.
Also you can try put http://www.gravatar.com/avatar/edb1260aa6f7f77688deee83e0a088f7?s=204&d=monsterid in your gravatarUrl. It will show picture.
Hope this helps someone , this is the code i used.
get library from:- https://github.com/tkeunebr/gravatar-android (you will get the .jar,, add it to lib)
Code for loading gravatar:
String gravatarUrl = Gravatar.init().with(user.email).size(100).build();
Picasso.with(mContext)
.load(gravatarUrl)
.into((ImageView) convertView.findViewById(R.id.user_avatar));
And if you want to set a default image in case of there is no gravatar set for the email(to override the default gravatar) then use:
String gravatarUrl = Gravatar.init().with(user.email).defaultImage(defaultImageUrl).size(100).build();
Hope this helps someone.

send email with image in android

I want email with image which is fatch from drowable in android I show bellow given link but same problem arise:
How to add an image in email body
and if I put
email.putExtra(Intent.EXTRA_TEXT,Html.fromHtml("<b>content</b>"+"<img src=\"data:"+getResources().getDrawable(R.drawable.smile)+";base64,#IMAGEDATA#\"‌​>")
and save it it give the Error:
Save Could not be completed
some character can not be mapped using "Cp1252" Character encodding.
please give me the solution, I want send image with mail.
Try this it will really help you:
mail.putExtra(Intent.EXTRA_SUBJECT, subject.toString());
mail.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:"+ file));

How to get twitter profile image using Twitter4j [duplicate]

I am using the Twitter4J API in Java to retrieve the profile image for a Twitter user whose logged in. The command is something like :
twitter.getProfileImage(twitter.getScreenName(), Imagesize);
What is the image size? How can I display the ProfileImage object in a label for example?
ok, the answer is :
Assume that the Twitter object is twitter
1 - get the user from the twitter object
User user = twitter.showUser(twitter.getid());
2 - get the profile image URL
URL url = user.getProfileImageURL();
3 - create Image icon
ImageIcon img = new ImageIcon(url);
4 - set the JLabel icon to be the ImageIcon
Jlabel1.setIcon(img);
Take a look at the example code.
https://github.com/yusuke/twitter4j/blob/master/twitter4j-examples/src/main/java/twitter4j/examples/user/GetProfileImage.java
You can pass either ProfileImage.MINI, ProfileImage.NORMAL or ProfileImage.BIGGER

Categories

Resources