当前位置: 编程技术>移动开发
本页文章导读:
▪APKTool运用教材 APKTool使用教材
第一步,把需要汉化的文件(以汉化ColorNote为例)放到APKTool所在目录,然后命令行进入APKTool目录,执行下面的命令:
apktool d ColorNote.apk ColorNote
这句命令的意思是,对Colo.........
▪ MediaScanner的使用 MediaScanner的应用
final String szFile = szFinalFileName;
m_pScanner = new MediaScannerConnection(this,
new MediaScannerConnectionClient() {
public void onMediaSc.........
▪ 图片下传 图片上传
private boolean handlePicture(String filePath, String mimeType) {
HttpURLConnection connection = null;
DataOutputStream outStream = null;
DataInputStream inStream = null;
String lineEnd = "\r\n";
String twoHyph.........
[1]APKTool运用教材
来源: 互联网 发布时间: 2014-02-18
APKTool使用教材
第一步,把需要汉化的文件(以汉化ColorNote为例)放到APKTool所在目录,然后命令行进入APKTool目录,执行下面的命令:
apktool d ColorNote.apk ColorNote
这句命令的意思是,对ColorNote.apk这个程序进行反编译,获得的文件放在当前目录下的ColorNote目录中。正常反编译的话,能看到下面的提示:
I: Baksmaling…
I: Decoding resource table…
I: Decoding resources…
I: Copying assets and libs…
反编译完成,会在APKTool的目录下面,出现一个名叫ColorNote的目录,
就在APKTool目录下执行下面的命令行:
apktool b ColorNote
这条命令是告诉APKTool,把这个ColorNote目录里的东西编译打包成APK程序
I: Checking whether sources has changed…
I: Smaling…
I: Checking whether resources has changed…
I: Building resources…
I: Building apk file…
生成的APK程序在哪里呢?在ColorNote\Dist目录里面,名字是out.apk
我们把这个out.apk文件签名之后安装看看?哈哈!
[2] MediaScanner的使用
来源: 互联网 发布时间: 2014-02-18
MediaScanner的应用
final String szFile = szFinalFileName; m_pScanner = new MediaScannerConnection(this, new MediaScannerConnectionClient() { public void onMediaScannerConnected() { m_pScanner.scanFile(szFile, null /*mimeType*/); } public void onScanCompleted(String path, Uri uri) { if (path.equals(szFile)) { MugMashView.this.runOnUiThread(new Runnable() { public void run() { Toast .makeText(getApplicationContext(), "Image now available in Home > Pictures", Toast.LENGTH_SHORT) .show(); } }); m_pScanner.disconnect(); } } }); m_pScanner.connect();
[3] 图片下传
来源: 互联网 发布时间: 2014-02-18
图片上传
private boolean handlePicture(String filePath, String mimeType) { HttpURLConnection connection = null; DataOutputStream outStream = null; DataInputStream inStream = null; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 1*1024*1024; String urlString = "http://www.yourwebserver.com/youruploadscript.php"; try { FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(new File(filePath)); } catch(FileNotFoundException e) { } URL url = new URL(/blog_article/urlString/index.html); connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.setDoOutput(true); connection.setUseCaches(false); connection.setRequestMethod("POST"); connection.setRequestProperty("Connection", "Keep-Alive"); connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary); outStream = new DataOutputStream(connection.getOutputStream()); outStream.writeBytes(addParam("someparam", "content of some param", twoHyphens, boundary, lineEnd)); outStream.writeBytes(twoHyphens + boundary + lineEnd); outStream.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + filePath +"\"" + lineEnd + "Content-Type: " + mimeType + lineEnd + "Content-Transfer-Encoding: binary" + lineEnd); outStream.writeBytes(lineEnd); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); buffer = new byte[bufferSize]; bytesRead = fileInputStream.read(buffer, 0, bufferSize); while (bytesRead > 0) { outStream.write(buffer, 0, bufferSize); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); bytesRead = fileInputStream.read(buffer, 0, bufferSize); } outStream.writeBytes(lineEnd); outStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); fileInputStream.close(); outStream.flush(); outStream.close(); } catch (MalformedURLException e) { Log.e("DEBUG", "[MalformedURLException while sending a picture]"); } catch (IOException e) { Log.e("DEBUG", "[IOException while sending a picture]"); } try { inStream = new DataInputStream( connection.getInputStream() ); String str; while (( str = inStream.readLine()) != null) { if(str=="1") { return true; } else { return false; } } inStream.close(); } catch (IOException e){ Log.e("DEBUG", "[IOException while sending a picture and receiving the response]"); } return false; } private String addParam(String key, String value, String twoHyphens, String boundary, String lineEnd) { return twoHyphens + boundary + lineEnd + "Content-Disposition: form-data; name=\"" + key + "\"" + lineEnd + lineEnd + value + lineEnd;
最新技术文章: