主頁(yè) > 服務(wù)與支持 > 開發(fā)平臺(tái) > 客戶端SDK參考 > Android Native SDK > 快速入門 快速入門
更新時(shí)間:2019-11-20
在開發(fā)的過程中請(qǐng)滿足如下環(huán)境要求。
環(huán)境和工具名稱 |
版本要求 |
---|---|
操作系統(tǒng) |
Windows 7專業(yè)版 |
Android Studio |
Android Studio3.0及以上版本 |
會(huì)議云服務(wù)的用戶帳號(hào) |
帳號(hào)可來源于華為公有云。開通方法請(qǐng)參見“開發(fā)前準(zhǔn)備”。 |
將SDK壓縮包解壓后相關(guān)文件拷貝到工程的libs路徑下。
application
Service
ui
<resources> <string name="app_name">HelloWorld</string> <string name="register_server">RegServer</string> <string name="server_port">ServerPort</string> <string name="account">Account</string> <string name="password">Password</string> <string name="login">Login</string> <string name="login_success">Login success</string> <string name="account_information_not_empty">Please enter your login parameters</string> <string name="set_permission_write">Please enable storage permission in the settings, otherwise the function will not be available.</string> </resources> |
targetSdkVersion版本需要在25及以上(targetSdkVersion 25)
apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "26.0.1" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.huawei.esdk.tup.helloworld" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { assets.srcDirs = ['assets', 'src/main/assets', 'src/main/assets/'] jniLibs.srcDirs = ['libs'] } instrumentTest.setRoot('tests') debug.setRoot('build-types/debug') release.setRoot('build-types/release') } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile 'com.google.code.gson:gson:2.3.1' implementation 'androidx.core:core:1.0.2' } |
<!-- uses permission --> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> |
總體結(jié)構(gòu)
--- src --- main --- java --- com.huawei.esdk.uc.helloworld.application --- ECApplication.java --- com.huawei.esdk.uc.helloworld.service ---TupLoginService.java --- com.huawei.esdk.uc.helloworld.ui ---LoginActivity.java ---res --- layout ---activity_login.xml --values ---strings.xml ---AndroidManifest.xml |
源碼鏈接:Hello World源碼文件。
代碼參考
<application android:name=".application.ECApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true"> <activity android:name=".ui.LoginActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> |
/** * Init int. * @param context the context * @param appPath the app path * @return the result */ public boolean startService(Context context, String appPath) { int ret; tsdkManager = TsdkManager.getInstance(context, appPath, ServiceNotify.getInstance()); /* Step 1, set log param */ TsdkLogParam logParam = new TsdkLogParam(); logParam.setFileCount(1); logParam.setLevel(TsdkLogLevel.TSDK_E_LOG_DEBUG); logParam.setMaxSizeKb(1024 * 4); logParam.setPath(Environment.getExternalStorageDirectory() + File.separator + "HelloWorld" + "/"); ret = tsdkManager.setConfigParam(logParam); if (ret != 0) { return false; } /* Step 2, init sdk */ TsdkAppInfoParam appInfoParam = new TsdkAppInfoParam(); appInfoParam.setClientType(TSDK_E_CLIENT_MOBILE); appInfoParam.setProductName("eSDK-Mobile"); appInfoParam.setDeviceSn("123"); appInfoParam.setSupportAudioAndVideoCall(1); appInfoParam.setSupportAudioAndVideoConf(0); appInfoParam.setSupportDataConf(0); appInfoParam.setSupportCtd(0); appInfoParam.setSupportEnterpriseAddressBook(0); appInfoParam.setSupportIm(0); appInfoParam.setSupportRichMediaMessage(0); ret = tsdkManager.init(appInfoParam); if (ret != 0) { return false; } return true; } |
@Override public void onTerminate() { super.onTerminate(); tsdkManager.uninit(); } |
/** * Authorize login boolean. * * @param regServer the reg server * @param serverPort the server port * @param sipNumber the sip number * @param password the password * @return the boolean */ public boolean authorizeLogin(String regServer, String serverPort, String sipNumber, String password) { int ret; TsdkLoginParam tsdkLoginParam = new TsdkLoginParam(); tsdkLoginParam.setUserId(1); tsdkLoginParam.setAuthType(TsdkAuthType.TSDK_E_AUTH_NORMAL); tsdkLoginParam.setUserName(sipNumber); tsdkLoginParam.setPassword(password); tsdkLoginParam.setServerAddr(regServer); tsdkLoginParam.setServerPort(Integer.parseInt(serverPort)); tsdkLoginParam.setServerVersion(""); tsdkLoginParam.setServerType(TsdkServerType.TSDK_E_SERVER_TYPE_PORTAL); tsdkLoginParam.setUserTiket(""); ret = TsdkManager.getInstance().getLoginManager().login(tsdkLoginParam); if (ret != 0) { return false; } return true; } |
@Override public void onEvtAuthSuccess(int i, TsdkImLoginParam tsdkImLoginParam) { TupLoginService.getInstance().handleAuthSuccess(); } public void handleAuthSuccess() { Log.d("TupLoginService", "onEvtAuthSuccess."); Intent intent = new Intent(); intent.setAction(TUP_REGISTER_EVENT); intent.putExtra(REGISTER_RESULT, 0); ECApplication.getApp().sendBroadcast(intent); } |
private BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (TupLoginService.TUP_REGISTER_EVENT.equals(action)) { int result = intent.getIntExtra(TupLoginService.REGISTER_RESULT, -1); switch (result) { case 0: Toast.makeText(LoginActivity.this, getString(R.string.login_success), Toast.LENGTH_LONG).show(); break; default: break; } } } }; |
分類 |
輸入信息 |
說明 |
---|---|---|
鑒權(quán)信息 |
RegServer |
注冊(cè)服務(wù)器地址 |
Server port |
服務(wù)器端口號(hào) |
|
Account |
服務(wù)號(hào)碼 |
|
Password |
eSDK鑒權(quán)密碼 |
以上信息需要在成功預(yù)約華為遠(yuǎn)程實(shí)驗(yàn)室后,從遠(yuǎn)程實(shí)驗(yàn)室獲取。
服務(wù)器地址、端口號(hào)、用戶名、密碼輸入完成后,單擊“登錄”按鈕,界面顯示“正在登錄,請(qǐng)稍后”,等待接口返回操作結(jié)果。