Back to project page BluetoothSppPro.
The source code is released under:
Apache License
If you think the Android project BluetoothSppPro listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package mobi.dzs.android.BLE_SPP_PRO; //from w w w. ja va2 s . com import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import mobi.dzs.android.util.LocalIOTools; import android.app.ActionBar; import android.app.Activity; import android.os.Environment; import android.widget.Toast; public class BaseActivity extends Activity{ /** * ??Action Bar????? * @return void * */ protected void enabledBack(){ /*????????????????????*/ ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); } /** * ????????SD??? * @param sData String ????????? * @return void * */ protected void save2SD(String sData){ String sRoot = null; String sFileName = null; String sPath = null; //??sd?????????,????????(?????'/') if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) sRoot = Environment.getExternalStorageDirectory().toString();//??????? else return; //???????? sFileName = (new SimpleDateFormat("MMddHHmmss", Locale.getDefault())).format(new Date()) + ".txt"; //??????????? sPath = sRoot.concat("/").concat(this.getString(R.string.app_name)); if (LocalIOTools.coverByte2File(sPath, sFileName, sData.getBytes())){ String sMsg = ("save to:").concat(sPath).concat("/").concat(sFileName); Toast.makeText(this, sMsg, Toast.LENGTH_LONG).show();//???? ???????? }else{ Toast.makeText(this, //???? ??????? getString(R.string.msg_save_file_fail), Toast.LENGTH_SHORT).show(); } } /** * ??????????????? * @param int iRawID ?????ID * @return String / null */ public String getStringFormRawFile(int iRawID){ InputStream is = this.getResources().openRawResource(iRawID); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i; try{ i = is.read(); while(i != -1){ baos.write(i); i = is.read(); } is.close(); return baos.toString().trim(); }catch (IOException e){ return null; } } }