Upload Image on Flickr with android - android

i need to integrate Flickr with android. I am done with authentication.i need to upload image to flickr but i am unaware how to do same.
i refer document : http://www.flickr.com/services/api/upload.api.html for the same.
Can anybody help me

//change your key and secreat key
private static final String API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; //$NON-NLS-1$
public static final String API_SEC = "xxxxxxxxxxxxx"; //$NON-NLS-1$
View.OnClickListener mFlickrClickListener = new View.OnClickListener() {
#Override
public void onClick(View v) {
if (fileUri == null) {
Toast.makeText(getApplicationContext(), "Please pick photo",
Toast.LENGTH_SHORT).show();
return;
}
Intent intent = new Intent(getApplicationContext(),
FlickrjActivity.class);
intent.putExtra("flickImagePath", fileUri.getAbsolutePath());
startActivity(intent);
}
};

Related

How to post images selected from gallery to Facebook wall from my android app?

I am trying to post image and text to my facebook wall from my own android app. I need to select the image from mobile gallery, but its not working. i am not getting what is the issue in this code. Can anyone please help me??
public class PostFacebook extends Activity{
private Facebook mFacebook;
private CheckBox mFacebookCb;
private ProgressDialog mProgress;
private static final int SELECT_PICTURE = 100;
byte[] inputData;
Uri selectedImageUri;
String imgString;
ImageView image;
private Handler mRunOnUi = new Handler();
private static final String APP_ID = "7************";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fbpost);
final EditText reviewEdit = (EditText) findViewById(R.id.revieew);
image = (ImageView) findViewById(R.id.imageView1);
mFacebookCb = (CheckBox) findViewById(R.id.cb_facebook);
mProgress = new ProgressDialog(this);
mFacebook = new Facebook(APP_ID);
SessionStore.restore(mFacebook, this);
if (mFacebook.isSessionValid()) {
mFacebookCb.setChecked(true);
String name = SessionStore.getName(this);
name = (name.equals("")) ? "Unknown" : name;
mFacebookCb.setText(" Facebook (" + name + ")");
}
((Button) findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
String review = reviewEdit.getText().toString();
try {
InputStream iStream = getContentResolver().openInputStream(selectedImageUri);
inputData = GetImage.getBytes(iStream);
imgString = Base64.encodeToString(inputData, Base64.DEFAULT);
Log.v("image_check", imgString);
Toast.makeText(PostFacebook.this, imgString, Toast.LENGTH_SHORT).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (review.equals(""))
return;
if (mFacebookCb.isChecked()) postToFacebook(review, imgString);
}
});
image.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
}
});
}
private void postToFacebook(String review, String image) {
mProgress.setMessage("Posting ...");
mProgress.show();
AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);
Bundle params = new Bundle();
params.putString("message", review);
params.putString("picture", image);
params.putString("name", "Hira Ghaffar");
params.putString("caption", "Innovent.net");
params.putString("description", "Innovent is an android app developed by iFish Technologies");
mAsyncFbRunner.request("me/feed", params, "POST", new WallPostListener());
}
private final class WallPostListener extends BaseRequestListener {
public void onComplete(final String response) {
mRunOnUi.post(new Runnable() {
#Override
public void run() {
mProgress.cancel();
Toast.makeText(PostFacebook.this, "Posted to Facebook", Toast.LENGTH_SHORT).show();
}
});
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
selectedImageUri = data.getData();
if (null != selectedImageUri) {
image.setImageURI(selectedImageUri);
}
}
}
}
}
Here, The complete example of share image on facebook wall.
http://simpledeveloper.com/how-to-share-an-image-on-facebook-in-android/

Using other app to send message to line app

I try the following code to send messages to line app. It works; however, before I send message,it will move to the line friends page and I have to choose friends whom I want to send the messages to. How could I modify the code that I could choose friends at code instead of choosing friends manually.
public class MainActivity extends AppCompatActivity {
static final int REQUEST_ACTION_PICK = 1;
public static final String PACKAGE_NAME = "jp.naver.line.android";
public static final String CLASS_NAME = "jp.naver.line.android.activity.selectchat.SelectChatActivity";
private List<ApplicationInfo> m_appList;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sendTextHandler(this);
}
public void sendTextHandler(MainActivity view) {
String sendText = ((TextView)findViewById(R.id.send_text)).getText().toString();
if(checkLineInstalled()){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName(PACKAGE_NAME, CLASS_NAME);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, sendText);
startActivity(intent);
}else{
Toast toast = Toast.makeText(this, "LINEがインストールされていません", Toast.LENGTH_SHORT);
toast.show();
}
}
private boolean checkLineInstalled(){
PackageManager pm = getPackageManager();
m_appList = pm.getInstalledApplications(0);
boolean lineInstallFlag = false;
for (ApplicationInfo ai : m_appList) {
if(ai.packageName.equals(PACKAGE_NAME)){
lineInstallFlag = true;
break;
}
}
return lineInstallFlag;
}
}
The code is from https://gist.github.com/ekos/3993270.
If you want to be able to open a specific user based on the ID you can do the following:
String userId = findUserId();
String sendText = "line://ti/p/~" + userId;
Intent intent = null;
try {
intent = Intent.parseUri(sendText, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException e) {
e.printStackTrace();
}
startActivity(intent);
If you want to make a message and then be able to choose who to send it to you can use the following:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("line://msg/text/" + getMessage()));
startActivity(intent);

All of my database User columns are marked as (undefined) Parse.com?

This is a strange problem that only started yesterday, and I can't think of anything in my code that would have changed anything. I'm setting up a User on Parse, which includes profile information. Now, for some reason (and I can't find ANYTHING about this particular issue online) when I submit the user profile information, while all of the related fields in the app are correctly retrieving the data from Parse (which means it's out there)... when I look at the User on Parse.com all of the fields are marked as (undefined). This is most likely a JSON error, but I can't figure out where it is coming from? Here's my code for the user to submit their profile... see anything? I will add... The user has already signed up in another activity preceding this one.
public class CreateProfileActivity extends AppCompatActivity {
private ParseUser mCurrentUser;
private ParseFile mUserProfilePic;
private EditText mFirstName;
private EditText mLastName;
private EditText mBusinessName;
private EditText mBusinessCategory;
private EditText mBusinessDescription;
private ImageView mProfilePicImageView;
private Button mSubmitInfoButton;
private Uri mProfilePicUri;
private Bitmap mProfilePicBitmap;
private byte[] mProfilePicByteArray;
private boolean mProfilePic = false;
private ProgressBar mProgressBar;
private CirclePhotoTransform mCirclePhotoTransform = new CirclePhotoTransform();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_profile);
//INITIALIZE ALL UI ELEMENTS...
mFirstName = (EditText) findViewById(R.id.firstNameField);
mLastName = (EditText) findViewById(R.id.lastNameField);
mBusinessName = (EditText) findViewById(R.id.businessNameField);
mBusinessCategory = (EditText) findViewById(R.id.businessCategoryField);
mBusinessDescription = (EditText) findViewById(R.id.businessDescriptionField);
mProfilePicImageView = (ImageView) findViewById(R.id.profilePicImageView);
mSubmitInfoButton = (Button) findViewById(R.id.submitProfileButton);
mProgressBar = (ProgressBar) findViewById(R.id.createProfileProgress);
mProgressBar.setVisibility(View.INVISIBLE);
//INITIALIZE PARSE USER
mCurrentUser = ParseUser.getCurrentUser();
mProfilePicImageView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
selectProfilePicture();
}
});
mSubmitInfoButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mProgressBar.setVisibility(View.VISIBLE);
if (mProfilePic) {
mUserProfilePic = new ParseFile(mCurrentUser.getUsername() + "ProfilePicture.png", mProfilePicByteArray);
mUserProfilePic.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
submitUserProfile();
} else {
Toast.makeText(CreateProfileActivity.this, "There was an error. " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
} else {
mProfilePicBitmap = ((BitmapDrawable) mProfilePicImageView.getDrawable()).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
mProfilePicBitmap.compress(Bitmap.CompressFormat.PNG, 70, stream);
mProfilePicByteArray = stream.toByteArray();
mUserProfilePic = new ParseFile(mCurrentUser.getUsername() + "ProfilePicture.png", mProfilePicByteArray);
mUserProfilePic.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
submitUserProfile();
} else {
Toast.makeText(CreateProfileActivity.this, "There was an error. " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
}
}
});
}
private void submitUserProfile() {
DateFormat formattedDate = new SimpleDateFormat("MMM d, yyyy");
Date date = Calendar.getInstance().getTime();
String creationDate = formattedDate.format(date);
mCurrentUser.put("firstName", mFirstName.getText().toString());
mCurrentUser.put("lastName", mLastName.getText().toString());
mCurrentUser.put("businessName", mBusinessName.getText().toString());
mCurrentUser.put("businessCategory", mBusinessCategory.getText().toString());
mCurrentUser.put("businessDescription", mBusinessDescription.getText().toString());
mCurrentUser.put("itemsSoldCount", 0);
mCurrentUser.put("creationDate", creationDate);
mCurrentUser.put("totalRevenue", "0.00");
mCurrentUser.put("userProfilePic", mUserProfilePic);
mCurrentUser.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
goToHomeScreen();
}
});
}
private void goToHomeScreen() {
Intent intent = new Intent(CreateProfileActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
private void selectProfilePicture() {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 5);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case 5:
getProfilePic(data);
break;
default:
break;
}
}
}
private void getProfilePic(Intent data) {
mProfilePicUri = data.getData();
try {
mProfilePicBitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), mProfilePicUri);
mProfilePicBitmap = mCirclePhotoTransform.transform(mProfilePicBitmap);
} catch (IOException e) {
e.printStackTrace();
}
if (mProfilePicBitmap != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
mProfilePicBitmap.compress(Bitmap.CompressFormat.PNG, 80, stream);
mProfilePicByteArray = stream.toByteArray();
}
mProfilePicImageView.setImageBitmap(mProfilePicBitmap);
mProfilePic = true;
}
Ok. So I haven't figured out why, so if anyone knows why please tell me why. When I switched the value being stored in mCurrentUser.put("totalRevenue", "0.00"); to mCurrentUser.put("totalRevenue", 0.00); which stores as a Number on Parse.com. I'm not sure why storing the value as a String was nullifying everything else that was being stored but it was. After the change, all the data appears and is saved to Parse.com.
Check exactly what's the error .... ur getting
public void done(ParseException e) {
if (e != null) {
goToHomeScreen();
}
else {
Log.d("Error", "Error: " + e.getMessage());
Toast.makeText(getApplicationContext(), " Error: "+e.getMessage() , Toast.LENGTH_SHORT).show();
}
}

Receiving No apps can perform this actions error

I am attempting to get my app to offer me a choice of what browser to use. I have assigned the URL to http://google.com. When I run it, I get a 'No apps can perform this actions' error. I'm missing something and i cant figure it out.
public class myClass{
static private final String URL = "http://www.google.com";
..
..
implicitActivationButton.setOnClickListener(new OnClickListener() {
// Call startImplicitActivation() when pressed
#Override
public void onClick(View v) {
startImplicitActivation();
}
});
private void startImplicitActivation() {
Log.i(TAG, "Entered startImplicitActivation()");
Intent baseIntent = new Intent(Intent.ACTION_SEND,Uri.parse(URL));
String title = "Choose Browser";
Intent chooserIntent = Intent.createChooser(baseIntent, title);
Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction());
startActivity(chooserIntent);
}
...
...
}
To view a Web page, use ACTION_VIEW, not ACTION_SEND.

Launch SMS using data from a scanned QR Code

I'm trying to start the SMS activity with the phone number from a scanned QR Code filled in. So far I've been able to get the activity to launch but the number and message fields are blank. Here's what I have, currently this is crashing the app:
else if(resultType.getParsedResultType() == ParsedResultType.SMS){
Button smsButton = (Button)findViewById(R.id.btn_send_sms);
smsButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v){
String smsUri = ResultsActivity.this.item.getContent();
Uri uri = Uri.parse(smsUri);
Intent i = new Intent(Intent.ACTION_VIEW);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.setType("vnd.android-dir/mms-sms");
i.setData(uri);
startActivity(i);
}
});
smsButton.setVisibility(View.VISIBLE);
}
The String smsUri contains the scanned string from the QR Code, "SMSTO:666-666-1234:hello". How can I get the SMS Activity to launch with the phone number and the message already entered into the number and body fields?
I saw this post:
Sending SMS using Intent does not add recipients on some devices
Would I need to parse the QR Code result myself and break it into the phone number and message, then add those as Extras like that example?
Got it!
Since I can't answer my own question yet here it is:
Okay, got it to work. I made a class to break the QR result into separate elements:
public class Sms {
public static String[] breakString(String s) {
String[] smsElements = s.split(":");
return smsElements;
}
}
Then changed the method I have above to:
else if(resultType.getParsedResultType() == ParsedResultType.SMS){
Button smsButton = (Button)findViewById(R.id.btn_send_sms);
smsButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v){
String smsUri = ResultsActivity.this.item.getContent();
String[] smsElements = Sms.breakString(smsUri);
Intent i = new Intent(Intent.ACTION_VIEW);
i.putExtra("address", smsElements[1]);
i.putExtra("sms_body", smsElements[2]);
i.setData(Uri.parse("smsto:" + smsElements[1]));
startActivity(i);
}
});
smsButton.setVisibility(View.VISIBLE);
}
Okay, got it to work. I made a class to break the QR result into separate elements:
public class Sms {
public static String[] breakString(String s) {
String[] smsElements = s.split(":");
return smsElements;
}
}
Then changed the method I have above to:
else if(resultType.getParsedResultType() == ParsedResultType.SMS){
Button smsButton = (Button)findViewById(R.id.btn_send_sms);
smsButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v){
String smsUri = ResultsActivity.this.item.getContent();
String[] smsElements = Sms.breakString(smsUri);
Intent i = new Intent(Intent.ACTION_VIEW);
i.putExtra("address", smsElements[1]);
i.putExtra("sms_body", smsElements[2]);
i.setData(Uri.parse("smsto:" + smsElements[1]));
startActivity(i);
}
});
smsButton.setVisibility(View.VISIBLE);
}

Categories

Resources