0

How to Put String Variable in following Code, Please Help me.

parameters.putString("attachment","{\"name\":\"Facebook application By Martin\",\"href\":\"http://www.google.com/\",\"caption\":\"By Google Technology \",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"http://4.bp.blogspot.com/-9RPH9UGDSsE/TcGjy3fAHlI/AAAAAAAAAeI/kuQXLE_G5Ew/s1600/Flag+Wallpaper+of+India+%25283%2529.jpg\",\"href\":\"http://s.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"for more tips click here\",\"href\":\"http://www.google.com/\"}}}");

I use Above Code for Upload Image on Facebook Wall.But i want to use string variable & pass following path from variable.

http://4.bp.blogspot.com/-9RPH9UGDSsE/TcGjy3fAHlI/AAAAAAAAAeI/kuQXLE_G5Ew/s1600/Flag+Wallpaper+of+India+%25283%2529.jpg

Thanks in Advance.

2 Answers 2

1

I suggest you to refer this link: String Resources in Android.

Now Just check this example in the given link:

Define the below string inside the strings.xml:

<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

Now from activity class, you can get string and pass parameter value as:

Resources res = getResources();
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount);

So this is the basic example for your reference.

You can also define your string value inside the strings.xml and pass the parameter as per your requirement.

Sign up to request clarification or add additional context in comments.

Comments

0
String myPath = "http://4.bp.blogspot.com/-9RPH9UGDSsE/TcGjy3fAHlI/AAAAAAAAAeI/kuQXLE_G5Ew/s1600/Flag+Wallpaper+of+India+%25283%2529.jpg";

String myUrl = "parameters.putString("attachment","{\"name\":\"Facebook application By Dipak Keshariya\",\"href\":\"http://www.arthisoft.com/\",\"caption\":\"By Google Technology \",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\" + myPath + \",\"href\":\"http://s.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"for more tips click here\",\"href\":\"http://www.google.com/\"}}}");
";

Look at how I have changed the url in your call by using the concatenation operator ' + myPath + '

This is very, very basic. You should start learning java if you want to become an Android developer.

On another note, on your picture, top left corner, are you really sure you are a "PROUND" indian ?? :D

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.