我是Android的初学者,有人可以为我提供从移动视频库上传视频并将其保存在解析服务器上的工作教程吗?提前致谢 ! `Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); intent.setType( “视频/ *”); startActivityForResult(intent,1);
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull
String[]
permissions, @NonNull int[] grantResults)
{
super.onRequestPermissionsResult(requestCode, permissions,
grantResults);
if (requestCode == 1)
{
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED)
{
getPhoto();
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED)
{
requestPermissions(new String[]
{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
} else {
getPhoto();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent
data)
{
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1 && resultCode==ChatActivity.RESULT_OK && data!=null)
{
try
{
VideoView mVideo=(VideoView) findViewById(R.id.videoView);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
byte[] byteArray =stream.toByteArray();
ParseFile file = new ParseFile("resume.mp4", byteArray);
ParseObject object = new ParseObject("Video");
object.put("video",file);
object.put("username",
ParseUser.getCurrentUser().getUsername());
object.saveInBackground(new SaveCallback()
{
@Override
public void done(ParseException e)
{
if(e==null)
{
Toast.makeText(ChatActivity.this,"Vidoe
Saved",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(ChatActivity.this,"Vidoe not
Saved",Toast.LENGTH_SHORT).show();
}
}
});
}
catch (Exception ex)
{
ex.printStackTrace();
}
}`
我已经在清单文件中授予了访问外部数据的权限!