2012-07-01 27 views

回答

4

嘗試使用PackageManagergetLaunchIntentForPackage()以及DropBox的包名稱,即com.dropbox.android。如果Dropbox未安裝,您將獲得PackageManager.NameNotFoundException

+0

我試過這個:\t Intent intent = getPackageManager()。getLaunchIntentForPackage(「com.dropbox.android」);但它不工作! – user1086494

+0

你有DropBox安裝嗎? –

+0

對不起....它是工作!!!我嘗試在沒有Dropbox的其他手機...非常感謝! – user1086494

2

如果你想要的是空空的dropbox共享一個文件,你可以使用ACTION_SEND:

Intent intent = new Intent(Intent.ACTION_SEND); 
startActivity(Intent.createChooser(intent, "title"); 

您還可以發送一個特定的文件:

Intent intent = new Intent(Intent.ACTION_SEND); 
intent.setType(fileType); 
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(file.getPath())); 
startActivity(Intent.createChooser(intent, "title")); 

看到這個article瞭解ACTION_SEND後面的約定。

+1

Uri.parse(file.getPath())不起作用。請改用Uri.fromFile(文件)。代碼的最後一行還有一個缺失的緊支架。我試圖編輯答案,但我的編輯被拒絕。 –

相關問題