Created
February 7, 2012 15:21
-
-
Save KellyRice/1760198 to your computer and use it in GitHub Desktop.
Bhang Code 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UploadVideoActivity extends Activity { | |
private KCSClient sharedClient; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Get the shared instance of the Kinvey Service client | |
sharedClient = ((KinveyVidUploadApp) getApplication()).getKinveyService(); | |
// In click listener for upload video | |
... new View.onClickListener() { | |
@Override | |
public void onClick(View v) { | |
Intent chooseVideo = new Intent(Intent.ACTION_GET_CONTENT); | |
chooseVideo.setType("video/*"); | |
startActivityForResult(chooseVideo, 1); | |
} | |
}); | |
} | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
if (requestcode == 1) { | |
if (resultCode == Activity.RESULT_OK) { | |
Uri selectedVideoUri = data.getData(); | |
// Create a kinvey resource instance | |
KinveyResource videoResource = new KinveyResource(sharedClient, “video_001.mp4”); | |
// upload it ! | |
videoResource.upload(selectedVideoUri, new KinveyCallback<Void>(){ | |
@Override | |
public void onSuccess(Void r) { | |
Toast.makeText(UploadVideoActivity.this, "Successfully uploaded", Toast.LENGTH_SHORT); | |
} | |
}); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment