Intents:
AndSMB provides Intents for third party applications. Intents available are:
  • Browse SMB server.
  • Pick file, folder, printer or named pipe on SMB server.
  • Upload files/folders from SDCard to a SMB server.
  • Download files/folders from a SMB server to SDCard.
  • Upload images/videos from gallery to a SMB server already setup in AndSMB.
Samples:

Browse SMB server:
You have to define a SMB server URL:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("smb://192.168.20.128:445"));

You can add SMB credentials:
intent.putExtra("smb_username", "guest");
//intent.putExtra("smb_password", "yourpassword");
//intent.putExtra("smb_domain", "YOURDOMAIN");

If credentials are not provided but required then AndSMB will prompt for login and password.

Setup optional share and/or remote folder:
//intent.putExtra("remote_folder", "/yourshare/folder");

Setup optional SMB preferences:
//intent.putExtra("smb_encoding", "UTF-8");


Finally start the Activity:
startActivityForResult(intent, BROWSE_REQUEST);

Nothing returned in onActivityResult method.

AndSMB Browse Intent

Pick file, folder or printer on SMB server:
You have to define a SMB server URL with PICK action:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setData(Uri.parse("smb://192.168.20.128:445"));

You can add SMB credentials:
intent.putExtra("smb_username", "guest");
//intent.putExtra("smb_password", "yourpassword");
//intent.putExtra("smb_domain", "YOURDOMAIN");

If credentials are not provided but required then AndSMB will prompt for login and password.

Setup optional share and/or remote folder:
//intent.putExtra("remote_folder", "/yourshare/folder");

Setup optional display preferences:
//intent.putExtra("explorer_title", "Select a file");
//intent.putExtra("browser_list_background_color", "99000000");


Finally start the Activity:
startActivityForResult(intent, PICK_REQUEST);

Selected path will be returned in onActivityResult method:
Uri uri = intent.getData();

AndSMB Pick Intent


Upload files from SDCard to SMB server:
You have to define a SMB server URL and upload command:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
Uri smbUri = Uri.parse("smb://192.168.20.128");
intent.setDataAndType(smbUri, "vnd.android.cursor.dir/lysesoft.andsmb.uri");
intent.putExtra("command_type", "upload");

You can add SMB credentials:
intent.putExtra("smb_username", "guest");
//intent.putExtra("smb_password", "yourpassword");
//intent.putExtra("smb_domain", "YOURDOMAIN");


Setup optional SMB preferences:
//intent.putExtra("smb_encoding", "UTF-8");


And define file(s) to upload and optional remote folder:
intent.putExtra("local_file1", "/sdcard/subfolder1/file1.zip");
intent.putExtra("local_file2", "/sdcard/subfolder2/file2.zip");
// Optional initial remote folder (it must exist before upload)
intent.putExtra("remote_folder", "/remotefolder/subfolder");


Finally start the Activity:
startActivityForResult(intent, UPLOAD_FILES_REQUEST);

Transfer info will be returned in onActivityResult method:
String status = intent.getStringExtra("TRANSFERSTATUS");
String files = intent.getStringExtra("TRANSFERAMOUNT");
String size = intent.getStringExtra("TRANSFERSIZE");
String time = intent.getStringExtra("TRANSFERTIME");

AndSMB Upload File Intent


Upload folder from SDCard to SMB server:
You have to define a SMB server URL and upload command:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
Uri smbUri = Uri.parse("smb://192.168.20.128");
intent.setDataAndType(smbUri, "vnd.android.cursor.dir/lysesoft.andsmb.uri");
intent.putExtra("command_type", "upload");

You can add SMB credentials:
intent.putExtra("smb_username", "guest");
//intent.putExtra("smb_password", "yourpassword");
//intent.putExtra("smb_domain", "YOURDOMAIN");


Setup optional SMB preferences:
//intent.putExtra("smb_encoding", "UTF-8");

And define folder(s) to upload and optional remote folder:
intent.putExtra("progress_title", "Uploading folder ...");
intent.putExtra("local_file1", "/sdcard/localfolder");
// Optional Initial remote folder (it must exist before upload)
intent.putExtra("remote_folder", "/remotefolder/uploadedfolder");;


Finally start the Activity:
startActivityForResult(intent, UPLOAD_FOLDER_REQUEST);

Transfer info will be returned in onActivityResult method:
String status = intent.getStringExtra("TRANSFERSTATUS");
String files = intent.getStringExtra("TRANSFERAMOUNT");
String size = intent.getStringExtra("TRANSFERSIZE");
String time = intent.getStringExtra("TRANSFERTIME");

AndSMB Upload Folder Intent



Download files from SMB server to SDCard:
You have to define a SMB server URL and download command:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
Uri smbUri = Uri.parse("smb://192.168.20.128");
intent.setDataAndType(smbUri, "vnd.android.cursor.dir/lysesoft.andsmb.uri");
intent.putExtra("command_type", "download");

You can add SMB credentials:
intent.putExtra("smb_username", "guest");
//intent.putExtra("smb_password", "yourpassword");
//intent.putExtra("smb_domain", "YOURDOMAIN");


Setup optional SMB preferences:
//intent.putExtra("smb_encoding", "UTF-8");

And define file(s) to download into a local folder:
intent.putExtra("remote_file1", "/remotefolder/subfolder/file1.zip");
intent.putExtra("remote_file2", "/remotefolder/subfolder/file2.zip");
// Target local folder where files will be downloaded.
intent.putExtra("local_folder", "/sdcard/localfolder");


Finally start the Activity to be closed after transfer:
intent.putExtra("close_ui", "true");
startActivityForResult(intent, DOWNLOAD_FILES_REQUEST);

Transfer status will be returned in onActivityResult method:
String status = intent.getStringExtra("TRANSFERSTATUS");
String files = intent.getStringExtra("TRANSFERAMOUNT");
String size = intent.getStringExtra("TRANSFERSIZE");
String time = intent.getStringExtra("TRANSFERTIME");

AndSMB Download File Intent


Download folder from SMB server to SDCard:
You have to define a SMB server URL and download command:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
Uri smbUri = Uri.parse("smb://192.168.20.128");
intent.setDataAndType(smbUri, "vnd.android.cursor.dir/lysesoft.andsmb.uri");
intent.putExtra("command_type", "download");

You can add SMB credentials:
intent.putExtra("smb_username", "guest");
//intent.putExtra("smb_password", "yourpassword");
//intent.putExtra("smb_domain", "YOURDOMAIN");


Setup optional SMB preferences:
//intent.putExtra("smb_encoding", "UTF-8");

And define folder(s) to download into a local folder:
intent.putExtra("progress_title", "Downloading folder ...");
// Remote folder to download (must not end with /).
intent.putExtra("remote_file1", "/remotefolder/uploadedfolder");
intent.putExtra("local_folder", "/sdcard/downloadedfolder");


Finally start the Activity to transfer:
startActivityForResult(intent, DOWNLOAD_FOLDER_REQUEST);

Transfer status will be returned in onActivityResult method:
String status = intent.getStringExtra("TRANSFERSTATUS");
String files = intent.getStringExtra("TRANSFERAMOUNT");
String size = intent.getStringExtra("TRANSFERSIZE");
String time = intent.getStringExtra("TRANSFERTIME");

AndSMB Download Folder Intent


Share from gallery:
You have to create a SEND Intent with image or video type:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/jpeg");

Then pass URI of item to share:
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://media/external/images/media/103"));

Finally start the Activity to transfer:
startActivityForResult(intent, SEND_REQUEST);

Transfer status will be returned in onActivityResult method:
String status = intent.getStringExtra("TRANSFERSTATUS");
String files = intent.getStringExtra("TRANSFERAMOUNT");
String size = intent.getStringExtra("TRANSFERSIZE");
String time = intent.getStringExtra("TRANSFERTIME");

AndSMB Share Intent


Properties:
The following table provides all properties available for AndSMB Intents:

Property Description  Required 
Intent action To upload or download use: Intent.ACTION_PICK
To browse remote folder use: Intent.ACTION_VIEW
To share from gallery: Intent.ACTION_SEND
Yes
Intent data SMB server URI. It must start with smb:// followed by hostname (or IP address) and port (optional). For instance: smb://yourserver.com:445
You can setup a share or a initial folder through remote_folder parameter defined below.

This parameter also allows selecting an existing AndSMB configuration through:
- alias://myandsmbalias

Finally, to share from gallery, it must not be set and gallery item URI must be available in extra bundle as Intent.EXTRA_STREAM property.
Yes
Intent type This parameter is required for Intent.ACTION_PICK, use: "vnd.android.cursor.dir/lysesoft.andsmb.uri". It is not needed Intent.ACTION_VIEW. For Intent.ACTION_SEND ot must starts with "image/*" or "video/*" or "audio/*". No
progress_title Title text displayed in progress windows when uploading or downloading. No
smb_username SMB username to login. No
smb_password SMB password to login.
No
smb_domain SMB domain to login. No
smb_encoding This parameter allows selecting charset for SMB server. For instance:
- UTF-8
- SHIFT-JIS
- CP1251
- EUC-KR
- BIG5
- GBK
No
command_type This parameter allows selecting transfer type for Intent.ACTION_PICK. Value could be:
- upload
- download
No
remote_fileX Set of parameters (X=1 to N) to define remote files/folders. For instance:
remote_file1 = /remotefolder/subfolder1/file1.zip
remote_file2 = /remotefolder/subfolder2/file2.zip
remote_file3 = /remotefolder/subfolder3
...
It can used for upload and download
No
local_fileX Set of parameters (X=1 to N) to define local files/folders. For instance:
local_file1 = /sdcard/subfolder1/file1.zip
local_file2 = /sdcard/subfolder2/file2.zip
local_file3 = /sdcard/subfolder3
...
It can be used for upload and download.
No
local_folder This parameter allows defining a local folder. It can used to select a target folder for download. For instance:
local_folder = /sdcard/localfolder
No
remote_folder This parameter allows defining a a share and/or a remote folder. It can used to select a target folder for upload. For instance:
remote_folder = /remotefolder/uploadedfolder
No
close_ui This parameter allows closing AndSMB progress window after transfer with Intent.ACTION_PICK. For instance:
close_ui = true
Notice that underlying SMB connection will be closed as soon as transfer activity is destroyed.
No

The following table provides all properties available for Intent returned by AndSMB:

Property Description  Always
returned  
TRANSFERSTATUS Report about status of transfer. It could be:
- COMPLETED
- FAILED
- CANCELLED
- UNKNOWN
Yes
TRANSFERAMOUNT Amount of files transferred. It is returned for completed transfers.
No
TRANSFERSIZE Size in bytes of overall transfer. It is returned for completed transfers. No
TRANSFERTIME Duration time of overall transfer. Yes
Intent.getData() File, folder, printer or named pipe selected. No

Note: If AndSMB is already running then calling an Intent will close all current SMB connections.

Download:

  Download AndSMBClient source code
V1.0 [zip]
 

AndSMBClient is a sample application demonstrating how to use Intents from thrid party applications. Each button triggers an Intent.

You can download source code to learn how to use such Intents.

AndSMB client




Sitemap | Privacy Statement | All company and/or product names are the property of their respective owners.