package com.heiko.myxlogtest2;
import android.Manifest;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import com.tencent.mars.xlog.Xlog;
public class MainActivity extends AppCompatActivity {
static {
System.loadLibrary("c++_shared");
System.loadLibrary("marsxlog");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},11);
String logPath = Environment.getExternalStorageDirectory().getPath() + "/123logsample/xlog";
String cachePath = Environment.getExternalStorageDirectory().getPath() + "/123logsample/xlog/cache";
// String logPath = getExternalFilesDir("log").getPath() + "/123logsample/xlog";
// String cachePath = getExternalFilesDir("log").getPath() + "/123logsample/xlog/cache";
Log.d("z-test", logPath);
Xlog.setConsoleLogOpen(true);
Xlog.appenderOpen(Xlog.LEVEL_DEBUG, Xlog.AppednerModeAsync, cachePath, logPath, "LOGSAMPLE", 10, "");
com.tencent.mars.xlog.Log.setLogImp(new Xlog());
Button btnPrint = findViewById(R.id.btn_print);
btnPrint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Hello", Toast.LENGTH_SHORT).show();
com.tencent.mars.xlog.Log.i("z-test","hello world!");
com.tencent.mars.xlog.Log.d("z-test","curr time:"+System.currentTimeMillis());
com.tencent.mars.xlog.Log.v("z-test","xxxxx");
com.tencent.mars.xlog.Log.e("z-test","eeeeee");
}
});
Button btnFlush = findViewById(R.id.btn_flush);
btnFlush.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
com.tencent.mars.xlog.Log.appenderFlush(true);
Toast.makeText(MainActivity.this, "Flush", Toast.LENGTH_SHORT).show();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
com.tencent.mars.xlog.Log.appenderClose();
Log.d("z-test", "onDestroy");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Mars_XLog_Sample.zip (53个子文件)
MyXLogTest2
gradlew 5KB
settings.gradle 48B
gradle
wrapper
gradle-wrapper.properties 244B
gradle-wrapper.jar 53KB
MyXLogTest2.iml 883B
.gradle
buildOutputCleanup
outputFiles.bin 24KB
cache.properties 59B
buildOutputCleanup.lock 17B
vcs-1
gc.properties 0B
5.4.1
executionHistory
executionHistory.bin 1.89MB
executionHistory.lock 17B
fileChanges
last-build.bin 1B
javaCompile
javaCompile.lock 17B
classAnalysis.bin 85KB
taskHistory.bin 31KB
fileContent
fileContent.lock 17B
vcsMetadata-1
fileHashes
fileHashes.bin 126KB
resourceHashesCache.bin 18KB
fileHashes.lock 17B
gc.properties 0B
local.properties 441B
gradlew.bat 2KB
gradle.properties 1KB
.gitignore 222B
app
src
androidTest
java
com
heiko
myxlogtest2
ExampleInstrumentedTest.java 785B
test
java
com
heiko
myxlogtest2
ExampleUnitTest.java 398B
main
jniLibs
armeabi-v7a
libc++_shared.so 642KB
libmarsxlog.so 114KB
AndroidManifest.xml 819B
res
mipmap-hdpi
ic_launcher.png 3KB
ic_launcher_round.png 5KB
mipmap-xxxhdpi
ic_launcher.png 9KB
ic_launcher_round.png 15KB
mipmap-xhdpi
ic_launcher.png 4KB
ic_launcher_round.png 7KB
mipmap-anydpi-v26
ic_launcher.xml 276B
ic_launcher_round.xml 276B
mipmap-mdpi
ic_launcher.png 2KB
ic_launcher_round.png 3KB
drawable
ic_launcher_background.xml 6KB
layout
activity_main.xml 760B
drawable-v24
ic_launcher_foreground.xml 2KB
values
colors.xml 214B
strings.xml 77B
styles.xml 394B
mipmap-xxhdpi
ic_launcher.png 6KB
ic_launcher_round.png 10KB
java
com
heiko
myxlogtest2
MainActivity.java 3KB
libs
app.iml 12KB
.gitignore 8B
build.gradle 1KB
proguard-rules.pro 772B
build.gradle 585B
共 53 条
- 1
资源评论
氦客
- 粉丝: 2w+
- 资源: 56
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功