[SOLVED] How can I get a list of my Files and Folders on my ftp Server?
I know how to connect and upload a file, but not how to get the directory list:
try {
FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName("176.28.25.46"));
ftpClient.login("******", "******");
System.out.println("status :: " + ftpClient.getStatus());
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
// Prepare file to be uploaded to FTP Server
File file = new File("default.prop");
FileInputStream ifile = new FileInputStream(file);
// Upload file to FTP Server
ftpClient.storeFile("/subdomains/giveyourapps/httpdocs/apps/default.prop",ifile);
ftpClient.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
But every code snipped that I found on google didn't work for me :-/
try {
FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName("176.28.25.46"));
ftpClient.login("******", "******");
System.out.println("status :: " + ftpClient.getStatus());
String toppath = new String();
FTPFile[] ftpDirs = ftpClient.listDirectories();
for (int i = 0; i < ftpDirs.length; i++) {
toppath = ftpDirs[0].getName();
Log.d("CONNECT", "Directories in the ftp server are "
+ ftpDirs[i].getName());
}
FTPFile[] ftpdirs2 = ftpClient.listFiles(toppath);
for (int i = 0; i < ftpdirs2.length; i++) {
Log.d("CONNECT",
"File i need is " + ftpdirs2[i].getName());
}
}
For everybody who has the same problem. It works now with that code: (Thanks to user1106888)
try {
FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName("176.28.25.46"));
ftpClient.login("******", "******");
System.out.println("status :: " + ftpClient.getStatus());
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
try{
String toppath = new String();
FTPFile[] ftpDirs = ftpClient.listDirectories();
for (int i = 0; i < ftpDirs.length; i++) {
toppath = ftpDirs[0].getName();
System.out.println("Directory->: " + ftpDirs[i].getName());
}
FTPFile[] ftpdirs2 = ftpClient.listFiles(toppath);
for (int i = 0; i < ftpdirs2.length; i++) {
System.out.println("Files->: " + ftpdirs2[i].getName());
}
}catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
Use this code and it should help
FTPFile[] ftpDirs = mFTPClient.listDirectories();
for (int i = 0; i < ftpDirs.length; i++) {
toppath = ftpDirs[0].getName();
Log.d("CONNECT", "Directories in the ftp server are "
+ ftpDirs[i].getName());
}
FTPFile[] ftpdirs2 = mFTPClient.listFiles(toppath);
for (int i = 0; i < ftpdirs2.length; i++) {
Log.d("CONNECT",
"File i need is " + ftpdirs2[i].getName());
}
You can use CkFtp2 API to easily get the FTP directory listing information. Like the following:
CkFtp2 ftp = new CkFtp2();
int n = ftp.get_NumFilesAndDirs();
if (n < 0) {
outStr += ftp.lastErrorText() + "\n";
tv.setText(outStr);
setContentView(tv);
return;
}
if (n > 0) {
for (int i = 0; i <= n - 1; i++) {
// Display the filename
outStr += ftp.getFilename(i) + "\n";
// Display the file size (in bytes)
outStr += ftp.GetSize(i) + "\n";
// Is this a sub-directory?
if (ftp.GetIsDirectory(i) == true) {
outStr += ".. this is a sub-directory" + "\n";
}
outStr += "--" + "\n";
}
}
Related
i am using Jcifs library.
i try this code is working copy parent directory and file but sub directory not copy..
calling function
for (int j = 0; j < AppConst.checkfilelist.size(); j++) {
String old = AppConst.checkfilelist.get(j);
Log.d("smb_c_check_item", "" + AppConst.checkfilelist.get(j));
copyToDirectory(old, AppConst.destinationpath);
}
Function
public int copyToDirectory(String old, String newDir) {
try {
SmbFile old_file = new SmbFile(old);
SmbFile temp_dir = new SmbFile(newDir);
Log.d("smb_c_sour:desti_dir", "" + old + "---" + newDir);
// copy file
if (old_file.isFile()) {
Log.d("smb_c_file","yes");
String file_name = old.substring(old.lastIndexOf("/"), old.length());
Log.d("smb_c_file_name", "" + file_name);
String servername="smb://+ ipaddress+/";
NtlmPasswordAuthentication auth1 = new NtlmPasswordAuthentication(servername, "", "");
// smb file path
SmbFile cp_smbfile = new SmbFile(newDir + file_name.substring(1),auth1);
Log.d(" smb_c_file_path", "" + cp_smbfile);
if (!cp_smbfile.exists())
cp_smbfile.createNewFile();
cp_smbfile.connect();
InputStream in = new FileInputStream(String.valueOf((old_file)));
SmbFileOutputStream sfos = new SmbFileOutputStream(cp_smbfile);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
sfos.write(buf, 0, len);
}
// copy directory
} else if (old_file.isDirectory()) {
String servername="smb://+ ipaddress+/";
NtlmPasswordAuthentication auth1 = new NtlmPasswordAuthentication(servername, "", "");
Log.d("smb_c_folder","yes");
String files[] = old_file.list();
int len = files.length;
Log.d("smb_c_dirlength", "" + len);
for(int i1=0;i1<len;i1++){
Log.d("smb_c_dir---",""+files[i1]);
}
// remove last character
old = old.substring(0, old.length() - 1);
// get dir name
String old_f = old.substring(old.lastIndexOf("/"), old.length());
Log.d("smb_c_old_f", "" + old_f);
//create smbfile path
SmbFile smbdir = new SmbFile(newDir + old_f.substring(1),auth1);
// create new directory
if (!smbdir.exists()) {
Log.d("smb_c_mkdir", "created");
smbdir.mkdirs();
//return -1;
}
Log.d("smb_c_dir", "" + smbdir);
for (int i = 0; i < len; i++) {
copyToDirectory(old + "/" + files[i], smbdir + "/");
Log.d("smb_copy_rec", "" + old + "/" + files[i] + ":" + smbdir + "/");
}
} else if (!temp_dir.canWrite())
Log.d("smb_c_dir_noperm","yes");
return -1;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
Thanx in advance for any suggestions or help.sorry for my bad eng..
i found solution..
public int copySdToSmb(String old, String newDir) {
try {
File copyfile = new File(old);
SmbFile temp_dir = new SmbFile(newDir);
if (copyfile.isFile()) {
SmbFile cp_smbfile = new SmbFile(newDir + copyfile.getName());
if (!cp_smbfile.exists())
cp_smbfile.createNewFile();
cp_smbfile.connect();
InputStream in = new FileInputStream(copyfile);
SmbFileOutputStream sfos = new SmbFileOutputStream(cp_smbfile);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
sfos.write(buf, 0, len);
}
in.close();
sfos.close();
} else if (copyfile.isDirectory()) {
String files[] = copyfile.list();
// get dir name
String old_f = old.substring(old.lastIndexOf("/"), old.length());
int len = files.length;
SmbFile smbdir = new SmbFile(newDir + old_f.substring(1));
// create new directory
if (!smbdir.exists()) {
smbdir.mkdirs();
//return -1;
}
for (int i = 0; i <= len; i++) {
copySdToSmb(old + "/" + files[i], smbdir + "/");
}
} else if (!temp_dir.canWrite()) {
return -1;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Exception e) {
}
return 0;
}
I am trying to download image and save it to db i download it and save i to BLOB field when want to retrieve it it get me null value.I search a lot and examine lots of things but I have no idea where is the problem :( .
save image part :
MyDataBase = new MyDatabase(this);
mydb = MyDataBase.getWritableDatabase();
byte[] tempval;
for (int j = 0; j < myarray.arrtitle.length; j++)
{
tempval = saveimage(myarray.arrpic.get(j),myarray.arrpath[j]);
mydb.execSQL("INSERT INTO news (title,content,image) VALUES (\"" + myarray.arrtitle[j] +
"\",\"" + myarray.arrcontent[j] + "\",\"" + tempval + "\")");
}
mydb.close()
saveimage() function :
try {
////////////////get bitmap to byte
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] image = bos.toByteArray();
return image;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
read from db:
try
{
String temp = null;
Bitmap tempbit = null;
ArrayList<Bitmap> tempbit2 = new ArrayList<Bitmap>();
ArrayList<String> tempstring = new ArrayList<String>();
MyDataBase = new MyDatabase(this);
mydb = MyDataBase.getReadableDatabase();
Cursor cu = mydb.rawQuery("SELECT * FROM news",null);
cu.moveToFirst();
for (int i = 0;i<cu.getCount();i++)
{
temp = cu.getString(cu.getColumnIndex("title"));
byte[] imag = cu.getBlob(cu.getColumnIndex("image"));
tempbit = BitmapFactory.decodeByteArray(imag, 0, imag.length); // i get null here
tempbit2.add(tempbit);
tempstring.add(temp);
cu.moveToNext();
Toast.makeText(getApplicationContext(), "" + tempbit + i, Toast.LENGTH_LONG).show();
}
////////////////////////////show in list view
ListViewAdapte adapter = new ListViewAdapte(Description.this, R.layout.listview, tempstring , tempbit2);
MyList.setAdapter(adapter);
MyList.setOnItemClickListener(this);
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(getApplicationContext(), "error on load from db", Toast.LENGTH_LONG).show();
}
When I Toast tempbit it gets me null
i should save picture as contentview
ContentValues tempval = new ContentValues();
for (int j = 0; j < myarray.arrtitle.length; j++)
{
mydb.execSQL("INSERT INTO news (title,content) VALUES (\"" + myarray.arrtitle[j] +
"\",\"" + myarray.arrcontent[j] + "\"" + ")");
}
for (int j = 0; j < myarray.arrpic.size(); j++)
{
tempval = saveimage(myarray.arrpic.get(j),myarray.arrpath[j]);
update ="title ='" + myarray.arrtitle[j] + "'" ;
mydb.update("news", tempval,update, null);
}
save image is possible with using contentview :)
I want my App to list all directories and files on my FTP-Server. This is the code from How to list ftp directories with android?:
FTPFile[] files = null;
files = ftpClient.listDirectories();
String path = null;
for (int i = 0; i < files.length; i++) {
path = files[0].getName();
Log.d("CONNECT", "Directories: "+ files[i].getName());
}
FTPFile[] files2 = ftpClient.listFiles(topPath);
for (int j = 0; j < files2.length; j++) {
Log.d("CONNECT", "Below " + files[j].getName()
+ " is " + files2[j].getName());
}
}
Now this works for only for the first two layers. How can I manage to get as deep as necessary so I can list files that in folders that are in folders that are in folders and so on?
Thanks in advance :)
Now what I tried (not quite) recursively:
{ ...
FTPFile[] files = ftpClient.listFiles();
listContent(files);
.... }
private void listContent(FTPFile[] file) throws IOException {
FTPFile[] list = ftpClient.listDirectories();
if (list != null) {
for (FTPFile f : list) {
if (f.isDirectory()) {
Log.d(TAG, "directory: " + f.getName());
} else {
Log.d(TAG, "file: " + f.getName());
}
}
listContent(list);
} else return;
}
This code lets me get just the first layer of directories, the FTPFile[] is overwritten in ever new cycle.
How can I do that?
UPDATE:
Here's my solution. This code walks the whole content of the host-adress. Thanks to all who helped me:
private void listContent(String s) throws IOException {
try {
FTPFile[] ftpFiles = ftpClient.listFiles(s);
int length = ftpFiles.length;
for (int i = 0; i < length; i++) {
String name = ftpFiles[i].getName();
boolean isFile = ftpFiles[i].isFile();
if (isFile) {
Log.i(TAG, "File : " + name);
}
} else {
Log.i(TAG, "Directory : " + name);
if (ftpChangeDirectory(name) == true) {
Log.d("ftpChangeDirectory", name);
String newDir = ftpGetCurrentWorkingDirectory();
Log.d(TAG, "new Dir: " + newDir);
listContent(newDir);
}
}
}
ftpChangeDirectory("..");
String test = ftpGetCurrentWorkingDirectory();
Log.d("dirUp", test);
} catch (Exception e) {
e.printStackTrace();
}
}
I can't test it but something like this should work :
private void listAllFiles(String path) // path is the top folder to start the search
{
FTPFile[] files = ftpClient.listFiles(path); // Search all the files in the current directory
for (int j = 0; j < files.length; j++) {
Log.d("CONNECT", "Files: " + files[j].getName()); // Print the name of each files
}
FTPFile[] directories = ftpClient.listDirectories(path); // Search all the directories in the current directory
for (int i = 0; i < directories.length; i++) {
String dirPath = directories[i].getName();
Log.d("CONNECT", "Directories: "+ dirPath); // Print the path of a sub-directory
listAllFiles(dirPath); // Call recursively the method to display the files in the sub-directory
}
}
Anyway, i strongly recommend that you understand the code and check this link to learn more about recursivity.
I try to write a program to read all the sector of NCF tag.So when I run the test :
the tag is detected
I get the tag Id
I get the number of sector
But i can only read the first sector !
Here my code :
public class MainActivity extends Activity {
public String TAG_LOCAL = "Home - ";
public boolean MODE_DEBUG_LOCAL = true;
NfcAdapter nfcAdapter;
PendingIntent pendingIntent;
IntentFilter[] intentFilter;
String[][] generalTechLists;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.w("ISI", "Main Start");
//detect if NFC device
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
Log.w("ISI", "NFC detected");
}else{
Log.w("ISI", "NFC NOT detected");
}
IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
try {
ndef.addDataType("*/*");
} catch (MalformedMimeTypeException e) {
Log.w("ISI", " error ndef = " + e.getMessage());
}
intentFilter = new IntentFilter[] {ndef};
generalTechLists = new String[][] { new String[] { MifareClassic.class.getName() } };
nfcAdapter = NfcAdapter.getDefaultAdapter(this);
pendingIntent = PendingIntent.getActivity(this, 0,new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
}
#Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
resolveIntent(intent);
}
void resolveIntent(Intent intent) {
String action = intent.getAction();
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
//Identifiant du tag NFC
byte[] byte_id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
Log.w("ISI", "Tag id = " + ByteArrayToHexString(byte_id));
//techno disponible
Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String[] techList = tagFromIntent.getTechList();
for (int Cpt = 0; Cpt <techList.length; Cpt++){
Log.w("ISI", "Techno = " + techList[Cpt]);
}
//QUESTION A POSER DANS XDA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MifareClassic mfc = MifareClassic.get(tagFromIntent);
try{
mfc.connect();
int size = mfc.getSize();
Log.w("ISI", "size (byte) = " + size);
int nbrSector = mfc.getSectorCount();
Log.w("ISI", "NbrSector = " + nbrSector);
for (int Cpt = 0; Cpt < nbrSector; Cpt++){
boolean auth = mfc.authenticateSectorWithKeyA(Cpt, MifareClassic.KEY_DEFAULT);
if (auth){
int nbrBlock = mfc.getBlockCountInSector(Cpt);
Log.w("ISI", "NbrBlock = " + nbrBlock + " for sector " + Cpt);
for (int k = 0; k < nbrBlock; k++){
byte[] data = mfc.readBlock(k);
Log.w("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
}
}else{
Log.w("ISI", " Impossible to connect at sector " + Cpt);
}
}
}catch(IOException e){
Log.w("ISI", " error = " + e.getMessage());
}
}// End of method
}
#Override
protected void onResume() {
super.onResume();
nfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFilter, generalTechLists);
}
private String getHexString(String hex){
StringBuilder output = new StringBuilder();
for (int i = 0; i < hex.length(); i+=2) {
String str = hex.substring(i, i+2);
output.append((char)Integer.parseInt(str, 16));
}
return output.toString();
}
String ByteArrayToHexString(byte[] inarray) {
//Thanks Adam Laurie sur XDA
int i, j, in;
String [] hex = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
String out= "";
for(j = 0 ; j < inarray.length ; ++j) {
in = (int) inarray[j] & 0xff;
i = (in >> 4) & 0x0f;
out += hex[i];
i = in & 0x0f;
out += hex[i];
}
return out;
}
}
And here the log :
Tag id = C44F0EDD
Techno = android.nfc.tech.MifareClassic
Techno = android.nfc.tech.NfcA
Techno = android.nfc.tech.NdefFormatable
size (byte) = 1024
NbrSector = 16
NbrBlock = 4 for sector 0
Block num 0 - data C44F0EDD58880400C185149849803612
Block num 1 - data 00000000000000000000000000000000
Block num 2 - data 00000000000000000000000000000000
Block num 3 - data 000000000000FF078069FFFFFFFFFFFF
NbrBlock = 4 for sector 1
error = Tag was lost.
So I don't understand what happens.
Thank for help
Try to change:
for (int k = 0; k < nbrBlock; k++){
byte[] data = mfc.readBlock(k);
Log.w("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
}
with this
byte[] data = mfc.readBlock(bIndex);
for (int k = 0; k < nbrBlock; k++){
bIndex = mfc.sectorToBlock(Cpt);
bIndex++;
Log.w("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
}
from: http://mifareclassicdetectiononandroid.blogspot.it/
Set your code like this:
int bIndex = 0;
try{
mfc.connect();
int size = mfc.getSize();
Log.i("ISI", "size (byte) = " + size);
int sectorCount = mfc.getSectorCount();
Log.i("ISI", "NbrSector = " + sectorCount);
for (int Cpt = 0; Cpt < sectorCount; Cpt++){
boolean auth = mfc.authenticateSectorWithKeyA(Cpt, MifareClassic.KEY_DEFAULT);
if (auth){
int nbrBlock = mfc.getBlockCountInSector(Cpt);
Log.i("ISI", "NbrBlock = " + nbrBlock + " for sector " + Cpt);
for (int k = 0; k < nbrBlock; k++){
byte[] data = mfc.readBlock(bIndex);
Log.i("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
bIndex++;
}
}else{
Log.i("ISI", " Impossible to connect at sector " + Cpt);
}
}
}catch(IOException e){
Log.i("ISI", " error = " + e.getMessage());
}
I am trying to send the send voice data immediately to local server using audiorecord.. I am able to record the voice & stores it in SDcard.. but I want to store audio voice in buffer & sends immediate to the server using HTTP POST. How can I proceed.got struck..? I am creating this app in ICS i.e android 4.0.3 version.
got the solutions.. sending voice data as a jsonarray to server & recieve back as a json object. convert back jsonobject to short array n write to audiotrack then play back. here is sample code working.
public void SendAudio() {
String LOG_TAG = null;
long SAMPLE_INTERVAL = 1;
Log.e(LOG_TAG, "start send thread, thread id: ");
int bytes_read = 0;
int bytes_count = 0;
br = br % 5;
br++;
try {
HttpClient httpclient = new DefaultHttpClient();
HttpClient httpclient_recv = new DefaultHttpClient();
// System.out.println("mmdata--------- " + value);
HttpPost httppost = new HttpPost("http://192.168.1.39/call");
HttpPost httppost_recv = new HttpPost("http://192.168.1.39/ping");
// Unix time stamp
long unixTime = System.currentTimeMillis();
String timestamp = String.valueOf(unixTime);
// Json Format
JSONObject holder = new JSONObject();
JSONObject holder_recv = new JSONObject();
JSONArray jArray = new JSONArray();
try {
holder.put("UserId", "1");
holder.put("TimeStamp", timestamp);
holder.put("SessionId", "1");
Queue<byte[]> qArray = new LinkedList<byte[]>();
qArray.add(bData);
byte[] tmparr = qArray.poll();
for (int i = 0; i < tmparr.length; i++) {
jArray.put(i, tmparr[i]);
}
System.out.println("send audio -- " + jArray);
holder.put("MMData", jArray.toString());
System.out.println("JSON -- " + holder.toString());
holder_recv.put("UserId", "1");
holder_recv.put("TimeStamp", timestamp);
holder_recv.put("SeqNo", "100");
holder_recv.put("SessionId", "0");
} catch (JSONException e1) {
e1.printStackTrace();
}
System.out.println("time " + timestamp);
try {
StringEntity se = new StringEntity(holder.toString());
StringEntity se_recv = new StringEntity(holder_recv.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
se_recv.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
httppost.setEntity(se);
httppost_recv.setEntity(se_recv);
HttpResponse response = httpclient.execute(httppost);
HttpResponse response_recv = httpclient_recv
.execute(httppost_recv);
if (response_recv != null) {
t = EntityUtils.toString(response_recv.getEntity());
System.out.println("after response -- " + t);
Queue<String> qe = new LinkedList<String>();
qe.add(t);
t = null;
System.out.println("on play side ...1 ");
try {
System.out.println("on play side ...2 ");
JSONObject get = new JSONObject(qe.poll());
// JSONArray jArray_recv = get.getJSONArray("MMData");
String mmdata = (String) get.get("MMData");
JSONObject temp2 = new JSONObject("{ \"MMData\" : "
+ mmdata + "}");
JSONArray jArray_recv = temp2.getJSONArray("MMData");
System.out.println("jsonarray -- " + jArray_recv);
// String timeData = (String) get.get("TimeStamp");
String userData = (String) get.get("UserId");
// String sessionId = (String) get.get("TimeStamp");
System.out.println("on play side ...3 ");
// if (Long.valueOf(timeData) > ts)
{
// ts = Long.valueOf(timeData);
System.out.println("on play side ...4 ");
if (at != null) {
System.out.println("on play side ...5 ");
byte[] shortArray = new byte[jArray_recv
.length()];
for (int i = 0; i < jArray_recv.length(); i++) {
shortArray[i] = (byte) jArray_recv
.getInt(i);
}
jArray_recv = null;
System.out.println("recv audio -- " + br
+ " ----" + shortArray);
byte[] temp = shortArray;
shortArray = null;
byte[] bArray = temp;
temp = null;
byte[][] newbarray = new byte[5][1024];
newbarray[br - 1] = bArray;
byte[] sbayyay = new byte[1024 * 5];
System.arraycopy(bArray, 0, sbayyay,
(br - 1) * 1024, bArray.length);
if (br == 5) {
for (int i = 0; i < 5; i++) {
System.out.println("in for---" + i
+ "----" + sbayyay.length);
// System.arraycopy(newbarray[i], 0,
// sbayyay, i * 1024,
// bArray.length);
}
System.out.println("bsbsbsbs --- "
+ new String(sbayyay));
at.write(sbayyay, 0, sbayyay.length);
at.play();
}
}
else {
Log.d("Audio",
"audio track is not initialised ");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
System.out.println("Exception");
e.printStackTrace();
}
bytes_count += bytes_read;
Log.d(LOG_TAG, "bytes_count : " + bytes_count);
Thread.sleep(SAMPLE_INTERVAL, 0);
} catch (InterruptedException ie) {
Log.e(LOG_TAG, "InterruptedException");
}
}