2012-07-23 99 views
0

我從畫廊拍攝了一張圖片,我想在另一個課堂上使用它。使用「uri」可能嗎?如何使用「uri」將圖像發送給其他課程? (android)

Uri selectedImage = data.getData(); 
String path = selectedImage.getPath(); 

Intent sintent = new Intent(FromFile.this, OurView.class); 
startActivity(sintent); 
+0

你要發送的'Path'或'Uri' – Praveenkumar 2012-07-23 13:55:55

+0

最好是使用http://developer.android。 com/reference/android/content/Intent.html#setDataAndType(android.net.Uri,java.lang.String)或類似的東西 – 2012-07-23 14:05:31

回答

1

創建意圖後添加此項。

sintent.putExtra("image", path); 

而且在OurView調用

String path = getIntent().getStringExtra("image"); 
0

你可以把你想在發件人Activity的意圖發送圖像的Uri。事情是這樣的:

Intent sintent = new Intent(FromFile.this, OurView.class); 
intent.putExtra("selectedImage", selectedImage.toString()); 
startActivity(sintent); 

然後進行檢索,在Activity使用此代碼是beeing稱爲:

//Where OurView is assumed to be the class name of your Activity that is being called 
Uri selectedImage = Uri.parse(OurView.this.getIntent().getExtras().getString("selectedImage")); 
0

1)如果你想傳遞的路徑下一個活動。如果你想開放的傳遞到下一個活動

String path = getIntent().getStringExtra("image"); 

2) - 嘗試這個 -

Intent sintent = new Intent(FromFile.this, OurView.class); 
sintent.putExtra("pathvalue", path); 
startActivity(sintent); 
在nextActivity(OurView.java)

。試試這個 -

Uri selectedImage = data.getData(); 
String path = selectedImage.getPath(); 

Intent intent = new Intent(FromFile.this, OurView.class); 
intent.setData(Uri.parse(selectedImage)); 
startActivity(intent); 
在nextActivity(OurView.java)

-

Uri selectedImage = getIntent().getData(); 
相關問題