Android Share Intent Video hochladen

  • 0 Antworten
  • Letztes Antwortdatum
Shila

Shila

Neues Mitglied
0
Huhu,
möchte mit einem Share Intent ein Video auf youtube hochladen, hab den Pfad auch schon und übergib den an das Share Intent, jedoch übernimmt er mir das in der App nicht, sprich ich kann zwar auf das youtube hochladen zugreifen nur da ist kein Video drin, wie kann ich das mit übergeben?

Code:
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		
	   if (resultCode == RESULT_OK) {
	        if (requestCode == 33) {
	          Uri selectedMediaUri = data.getData();
	            filemanagerstring = selectedMediaUri.getPath();
	            selectedMediaPath = getPath(selectedMediaUri);
	            if (!selectedMediaPath.equals("")) {
	                filePath = selectedMediaPath;
	               
	            } else if (!filemanagerstring.equals("")) {
	                filePath = filemanagerstring;
	            }
	            int lastIndex = filePath.lastIndexOf("/");
	            fileName = filePath.substring(lastIndex+1);
	            //filepath is your file's path
	            System.out.println(filePath);
	            shareContent();
	        }
	   }
	   
	}
	
	public String getPath(Uri uri) {
	    String[] projection = { MediaStore.MediaColumns.DATA };
	    Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
	    if (cursor != null) {
	        // HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL
	        // THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA
	        int column_index = cursor
	                .getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
	        cursor.moveToFirst();
	        return cursor.getString(column_index);
	    } else
	        return "";
		
		
	}
	
	public void selectVideo()
	{
		Intent data = new Intent(Intent.ACTION_GET_CONTENT);
		data.setType("video/*");
		try {
			startActivityForResult(Intent.createChooser(data, "Select a video.." ), 33);
			System.out.println("Breakpoint");
		} catch (android.content.ActivityNotFoundException ex) {
			Toast.makeText(OpenChallengesActivity.this,
					"There are no Videos..", Toast.LENGTH_SHORT).show();
		}
	}
	
	public void recordVideo()
	{
		Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
	    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) 
	    {
	        startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
	    }
	}
	
	public void shareContent ()
	{

	Intent sendIntent = new Intent();
	sendIntent.setAction(Intent.ACTION_SEND);
	sendIntent.putExtra(Intent.EXTRA_TEXT, Uri.parse(filePath));
	sendIntent.setType("video/*");
	startActivity(sendIntent);
		
	ContentValues content = new ContentValues(4);
	content.put(Video.VideoColumns.DATE_ADDED,
	System.currentTimeMillis() / 1000);
	content.put(Video.Media.MIME_TYPE, "video/*");
	content.put(MediaStore.Video.Media.DATA, "video_path");
	ContentResolver resolver = getBaseContext().getContentResolver();
	Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);

//		Intent sharingIntent = new Intent();
//		sharingIntent.setAction(Intent.ACTION_SEND);
//		sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title");
//		sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,filePath);
//		startActivity(sharingIntent); 
	}

Die selectVideo und recordVideo werden in einem alert aufgerufen!

Bitte um schnelle hilfe :)

Danke :)
 

Ähnliche Themen

M
Antworten
21
Aufrufe
1.360
swa00
swa00
Mr-Fisch
Antworten
5
Aufrufe
966
migi01
migi01
Mr-Fisch
Antworten
8
Aufrufe
1.006
Mr-Fisch
Mr-Fisch
M
Antworten
9
Aufrufe
790
mkuz24
M
A
Antworten
5
Aufrufe
694
swa00
swa00
Zurück
Oben Unten