<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<project version="4"> | <project version="4"> | ||||
<component name="CompilerConfiguration"> | <component name="CompilerConfiguration"> | ||||
<bytecodeTargetLevel target="9" /> | |||||
<bytecodeTargetLevel target="1.8" /> | |||||
</component> | </component> | ||||
</project> | </project> |
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<project version="4"> | <project version="4"> | ||||
<component name="GradleMigrationSettings" migrationVersion="1" /> | |||||
<component name="GradleSettings"> | <component name="GradleSettings"> | ||||
<option name="linkedExternalProjectsSettings"> | <option name="linkedExternalProjectsSettings"> | ||||
<GradleProjectSettings> | <GradleProjectSettings> | ||||
<option name="testRunner" value="PLATFORM" /> | |||||
<option name="distributionType" value="DEFAULT_WRAPPED" /> | <option name="distributionType" value="DEFAULT_WRAPPED" /> | ||||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||||
<option name="modules"> | <option name="modules"> | ||||
<set> | <set> | ||||
<option value="$PROJECT_DIR$" /> | <option value="$PROJECT_DIR$" /> | ||||
<option value="$PROJECT_DIR$/app" /> | <option value="$PROJECT_DIR$/app" /> | ||||
<option value="$PROJECT_DIR$/tpmslibrary" /> | |||||
</set> | </set> | ||||
</option> | </option> | ||||
<option name="resolveModulePerSourceSet" value="false" /> | <option name="resolveModulePerSourceSet" value="false" /> | ||||
<option name="useQualifiedModuleNames" value="true" /> | |||||
</GradleProjectSettings> | </GradleProjectSettings> | ||||
</option> | </option> | ||||
</component> | </component> |
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="RemoteRepositoriesConfiguration"> | |||||
<remote-repository> | |||||
<option name="id" value="central" /> | |||||
<option name="name" value="Maven Central repository" /> | |||||
<option name="url" value="https://repo1.maven.org/maven2" /> | |||||
</remote-repository> | |||||
<remote-repository> | |||||
<option name="id" value="jboss.community" /> | |||||
<option name="name" value="JBoss Community repository" /> | |||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> | |||||
</remote-repository> | |||||
<remote-repository> | |||||
<option name="id" value="BintrayJCenter" /> | |||||
<option name="name" value="BintrayJCenter" /> | |||||
<option name="url" value="https://jcenter.bintray.com/" /> | |||||
</remote-repository> | |||||
<remote-repository> | |||||
<option name="id" value="Google" /> | |||||
<option name="name" value="Google" /> | |||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" /> | |||||
</remote-repository> | |||||
<remote-repository> | |||||
<option name="id" value="maven" /> | |||||
<option name="name" value="maven" /> | |||||
<option name="url" value="https://jitpack.io" /> | |||||
</remote-repository> | |||||
</component> | |||||
</project> |
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> | <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> | ||||
</configurations> | </configurations> | ||||
</component> | </component> | ||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |||||
<output url="file://$PROJECT_DIR$/build/classes" /> | <output url="file://$PROJECT_DIR$/build/classes" /> | ||||
</component> | </component> | ||||
<component name="ProjectType"> | <component name="ProjectType"> |
compileSdkVersion 29 | compileSdkVersion 29 | ||||
buildToolsVersion "29.0.2" | buildToolsVersion "29.0.2" | ||||
defaultConfig { | defaultConfig { | ||||
applicationId "aicare.net.cn.sdk.tmpsrepositoryandroid" | |||||
applicationId "aicare.net.cn.sdk.tmpsdemoandroid" | |||||
minSdkVersion 19 | minSdkVersion 19 | ||||
targetSdkVersion 29 | targetSdkVersion 29 | ||||
versionCode 1 | |||||
versionName "1.0" | |||||
versionCode 2 | |||||
versionName "1.1" | |||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||||
} | } | ||||
buildTypes { | buildTypes { | ||||
testImplementation 'junit:junit:4.12' | testImplementation 'junit:junit:4.12' | ||||
androidTestImplementation 'androidx.test:runner:1.2.0' | androidTestImplementation 'androidx.test:runner:1.2.0' | ||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||||
implementation project(path: ':tpmslibrary') | |||||
implementation 'com.github.elinkthings:TmpsSDKRepositoryAndroid:1.2.9' | |||||
} | } |
import android.content.Intent; | import android.content.Intent; | ||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.os.Handler; | import android.os.Handler; | ||||
import android.os.Looper; | |||||
import android.os.Message; | import android.os.Message; | ||||
import android.text.TextUtils; | import android.text.TextUtils; | ||||
import android.view.View; | import android.view.View; | ||||
import android.widget.ListView; | import android.widget.ListView; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import com.pingwang.tpmslibrary.TpmsSDK; | |||||
import com.pingwang.tpmslibrary.TpmsScan; | import com.pingwang.tpmslibrary.TpmsScan; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
setContentView(R.layout.activity_main); | setContentView(R.layout.activity_main); | ||||
TpmsSDK.init(this); | |||||
L.isDebug = true; | L.isDebug = true; | ||||
initData(); | initData(); | ||||
initViews(); | initViews(); | ||||
@Override | @Override | ||||
public void onGetData(String mac, String deviceId, int rssi, float pressure, float battery, | |||||
int temp, int status, float mcuVersion, int year, int month, int day, | |||||
public void onGetData(byte[] bytes,String mac, String deviceId, int rssi, float pressure,int pressureUnit, float battery, | |||||
int temp,int tempUnit, int status, float mcuVersion, int year, int month, int day, | |||||
float bleVersion) { | float bleVersion) { | ||||
if (deviceIdMap != null) { | if (deviceIdMap != null) { | ||||
lv_show_log.setSelection(infoList.size() - 1); | lv_show_log.setSelection(infoList.size() - 1); | ||||
} | } | ||||
private Handler handler = new android.os.Handler() { | |||||
private Handler handler = new android.os.Handler(Looper.getMainLooper()) { | |||||
@Override | @Override | ||||
public void handleMessage(Message msg) { | public void handleMessage(Message msg) { | ||||
String result = msg.getData().getString(RESULT); | String result = msg.getData().getString(RESULT); |
<resources> | <resources> | ||||
<string name="app_name">TmpsRepositoryAndroid</string> | |||||
<string name="app_name">TmpsDemoAndroid</string> | |||||
<string name="left_front_id">左前:%1$s</string> | <string name="left_front_id">左前:%1$s</string> | ||||
<string name="right_front_id">右前:%1$s</string> | <string name="right_front_id">右前:%1$s</string> |
repositories { | repositories { | ||||
google() | google() | ||||
jcenter() | jcenter() | ||||
maven { url 'https://jitpack.io' } | |||||
} | } | ||||
} | } | ||||
include ':app', ':tpmslibrary' | |||||
include ':app' |
/build |
apply plugin: 'com.android.library' | |||||
android { | |||||
compileSdkVersion 29 | |||||
buildToolsVersion "29.0.2" | |||||
defaultConfig { | |||||
minSdkVersion 19 | |||||
targetSdkVersion 29 | |||||
versionCode 1 | |||||
versionName "1.0" | |||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | |||||
} | |||||
buildTypes { | |||||
release { | |||||
minifyEnabled false | |||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | |||||
} | |||||
} | |||||
sourceSets { | |||||
main { | |||||
jniLibs.srcDirs = ['libs'] | |||||
} | |||||
} | |||||
} | |||||
dependencies { | |||||
implementation fileTree(dir: 'libs', include: ['*.jar']) | |||||
implementation 'androidx.appcompat:appcompat:1.1.0' | |||||
testImplementation 'junit:junit:4.12' | |||||
androidTestImplementation 'androidx.test:runner:1.2.0' | |||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | |||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41" | |||||
api files('libs/tpmslib.jar') | |||||
} |
# Add project specific ProGuard rules here. | |||||
# You can control the set of applied configuration files using the | |||||
# proguardFiles setting in build.gradle. | |||||
# | |||||
# For more details, see | |||||
# http://developer.android.com/guide/developing/tools/proguard.html | |||||
# If your project uses WebView with JS, uncomment the following | |||||
# and specify the fully qualified class name to the JavaScript interface | |||||
# class: | |||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | |||||
# public *; | |||||
#} | |||||
# Uncomment this to preserve the line number information for | |||||
# debugging stack traces. | |||||
#-keepattributes SourceFile,LineNumberTable | |||||
# If you keep the line number information, uncomment this to | |||||
# hide the original source file name. | |||||
#-renamesourcefileattribute SourceFile |
package aicare.net.cn.sdk.tpmslibrary; | |||||
import android.content.Context; | |||||
import androidx.test.InstrumentationRegistry; | |||||
import androidx.test.runner.AndroidJUnit4; | |||||
import org.junit.Test; | |||||
import org.junit.runner.RunWith; | |||||
import static org.junit.Assert.*; | |||||
/** | |||||
* Instrumented test, which will execute on an Android device. | |||||
* | |||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |||||
*/ | |||||
@RunWith(AndroidJUnit4.class) | |||||
public class ExampleInstrumentedTest { | |||||
@Test | |||||
public void useAppContext() { | |||||
// Context of the app under test. | |||||
Context appContext = InstrumentationRegistry.getTargetContext(); | |||||
assertEquals("aicare.net.cn.sdk.tpmslibrary.test", appContext.getPackageName()); | |||||
} | |||||
} |
<manifest package="aicare.net.cn.sdk.tpmslibrary" | |||||
xmlns:android="http://schemas.android.com/apk/res/android"/> |
<resources> | |||||
<string name="app_name">TpmsLibrary</string> | |||||
</resources> |
package aicare.net.cn.sdk.tpmslibrary; | |||||
import org.junit.Test; | |||||
import static org.junit.Assert.*; | |||||
/** | |||||
* Example local unit test, which will execute on the development machine (host). | |||||
* | |||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |||||
*/ | |||||
public class ExampleUnitTest { | |||||
@Test | |||||
public void addition_isCorrect() { | |||||
assertEquals(4, 2 + 2); | |||||
} | |||||
} |