当前位置: 编程技术>移动开发
本页文章导读:
▪应用Java自带的keytool命令 使用Java自带的keytool命令使用Java自带的keytool命令,在命令行生成。
1、生成服务器端私钥kserver.keystore文件
keytool -genkey -alias serverkey -validity 1 -keystore kserver.keystore
2、根据私钥,导.........
▪ QT 等候对话框/进度- QT 等待对话框/进度--用QT的,加载的一张gif图片。记录下来以后免得忘记。
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QLabel>
#include<QPainter>
#include<QMovie>
class Dialog : publ.........
▪ JNI范例1-扫描SD卡中mp3文件 JNI实例1---扫描SD卡中mp3文件 最近在研究JNI编程,顺便实现了一个小demo,使用native递归的方法,遍历手机sd卡目录的mp3文件,在JNI层,输出MP3文件的绝对路径。在执行效率上,与Java.........
[1]应用Java自带的keytool命令
来源: 互联网 发布时间: 2014-02-18
使用Java自带的keytool命令
使用Java自带的keytool命令,在命令行生成。
1、生成服务器端私钥kserver.keystore文件
keytool -genkey -alias serverkey -validity 1 -keystore kserver.keystore
2、根据私钥,导出服务器端安全证书
keytool -export -alias serverkey -keystore kserver.keystore -file server.crt
3、将服务器端证书,导入到客户端的Trust KeyStore中
keytool -import -alias serverkey -file server.crt -keystore tclient.keystore
4、生成客户端私钥kclient.keystore文件
keytool -genkey -alias clientkey -validity 1 -keystore kclient.keystore
5、根据私钥,导出客户端安全证书
keytool -export -alias clientkey -keystore kclient.keystore -file client.crt
6、将客户端证书,导入到服务器端的Trust KeyStore中
keytool -import -alias clientkey -file client.crt -keystore tserver.keystore
生成的文件分成两组,服务器端保存:kserver.keystore tserver.keystore 客户端保存:kclient.keystore tclient.kyestore。
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
keytool -genkey -alias clientkey -validity 1 -keystore kclient.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
keytool -import -alias clientkey -file android.crt -keystore kclient.bks -storetype BKS
keytool -import -alias csswebkey -file ca.crt -keystore kclient.bks -storetype BKS
keytool -import -alias cakey -file ca.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore client.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
使用Java自带的keytool命令,在命令行生成。
1、生成服务器端私钥kserver.keystore文件
keytool -genkey -alias serverkey -validity 1 -keystore kserver.keystore
2、根据私钥,导出服务器端安全证书
keytool -export -alias serverkey -keystore kserver.keystore -file server.crt
3、将服务器端证书,导入到客户端的Trust KeyStore中
keytool -import -alias serverkey -file server.crt -keystore tclient.keystore
4、生成客户端私钥kclient.keystore文件
keytool -genkey -alias clientkey -validity 1 -keystore kclient.keystore
5、根据私钥,导出客户端安全证书
keytool -export -alias clientkey -keystore kclient.keystore -file client.crt
6、将客户端证书,导入到服务器端的Trust KeyStore中
keytool -import -alias clientkey -file client.crt -keystore tserver.keystore
生成的文件分成两组,服务器端保存:kserver.keystore tserver.keystore 客户端保存:kclient.keystore tclient.kyestore。
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
keytool -genkey -alias clientkey -validity 1 -keystore kclient.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
keytool -import -alias clientkey -file android.crt -keystore kclient.bks -storetype BKS
keytool -import -alias csswebkey -file ca.crt -keystore kclient.bks -storetype BKS
keytool -import -alias cakey -file ca.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore client.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
[2] QT 等候对话框/进度-
来源: 互联网 发布时间: 2014-02-18
QT 等待对话框/进度--
用QT的,加载的一张gif图片。记录下来以后免得忘记。
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QLabel>
#include<QPainter>
#include<QMovie>
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
QMovie *movie;
QLabel *label;
};
#endif // DIALOG_H
#include"dialog.h"
Dialog::Dialog(QWidget*parent):
QDialog(parent)
{
label = new QLabel(this);
this->setFixedSize(200,200);
setWindowOpacity(0.5); //设置透明用;
this->setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint);
//取消对话框标题
//this->setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
//取消对话框标题和边框
//this->setAutoFillBackground(true);
this->setContentsMargins(0,0,0,0);
label->setContentsMargins(0,0,0,0);
/*QPalettepalette;palette.setBrush(QPalette::Background,QBrush(QPixmap("E:/qml/imgdialog/loading.gif")));
this->setPalette(palette)*/;
movie = new QMovie("loading.gif");
label->setMovie(movie);
movie->start();
}
Dialog::~Dialog()
{
delete label;
delete movie;
}
[3] JNI范例1-扫描SD卡中mp3文件
来源: 互联网 发布时间: 2014-02-18
JNI实例1---扫描SD卡中mp3文件
最近在研究JNI编程,顺便实现了一个小demo,使用native递归的方法,遍历手机sd卡目录的mp3文件,在JNI层,输出MP3文件的绝对路径。在执行效率上,与Java实现方式进行比对,确实native层的C代码明显好很多。
最近在研究JNI编程,顺便实现了一个小demo,使用native递归的方法,遍历手机sd卡目录的mp3文件,在JNI层,输出MP3文件的绝对路径。在执行效率上,与Java实现方式进行比对,确实native层的C代码明显好很多。
此demo比较简单,复杂之处在于C函数的实现。由于长期从事Java开发,导致C语言的东西都遗忘不少。
void Java_com_coder80_scaner1_MainActivity_scanDir(JNIEnv *env, jobject obj, jstring jdirPath)
{
const char *path = (*env)->GetStringUTFChars(env,jdirPath,NULL);
LOGE("begin to call scan_dir() in the JNI,and path = %s \n",path);
scan_dir(path);
}
void scan_dir(const char *directory)
{
DIR *dp;
struct dirent *entry;
struct stat statbuf;
if((dp = opendir(directory)) == NULL)
{
perror("opendir");
return;
}
chdir(directory);
//LOGE("pyb chdir directory = %s\n",directory);
while ((entry = readdir(dp)) != NULL) {
stat(entry->d_name, &statbuf);
if (S_ISDIR(statbuf.st_mode)) {
if ((strcmp(entry->d_name, ".") != 0)
&& (strcmp(entry->d_name, "..") != 0)
&& (entry->d_name[0] != '.')) {
scan_dir(entry->d_name);
}
} else {
int size = strlen(entry->d_name);
if (entry->d_name[0] != '.'
&& (statbuf.st_size/1024) > 300 //大于300k,表示肯能有mp3文件(忽略 <300k的mp3)
&& strcmp(entry->d_name + (size - 4), ".mp3") == 0){
//LOGE("scan_dir(),file st_size = %d \n\n",(statbuf.st_size/1024));
char* parentPath = (char*)malloc(1024);
char* absolutePath = (char*)malloc(1024);
//首先获取工作路径
getcwd(parentPath,1024);
//LOGE("parentPath = %s \n", parentPath);
strcpy(absolutePath,parentPath);
char *p = "/";
absolutePath = strcat(absolutePath,p);
absolutePath = strcat(absolutePath,entry->d_name);
//statbuf.st_size,
LOGE("scan_dir(),file absolutePath = %s \n", absolutePath);
free(parentPath);
parentPath = NULL;
free(absolutePath);
absolutePath = NULL;
}
}
}
chdir("..");
closedir(dp);
}
此demo虽说可以比对native与Java执行的效率,但是代码中native函数效率依然较低。市面上一些音乐播放器,例如酷狗和多米音乐,他们app中就有扫描sd卡音频文件的功能,其执行速度比我demo中要快很多,效率为我demo中的5倍左右。
博客中已经将代码上传,扫描sd卡中MP3的效率确实存在问题,如何能够提升代码执行效率,目前没有好的思路。各位大侠,如果有好的建议,不妨提供一下思路,先谢谢!
Android JNI层实现扫描sd卡mp3文件:
http://download.csdn.net/detail/coder80/5071729
最新技术文章: