- 追加された行はこの色です。
- 削除された行はこの色です。
- DchaLib は削除されています。
#author("2022-01-27T00:47:45+09:00","default:hitler","hitler")
*DchaService・DchaUtilServiceのライブラリ [#k99c03a2]
#author("2023-10-06T14:42:35+09:00","default:hitler","hitler")
|ファイル名|DchaLibrary|
|ダウンロード|[[ダウンロード>https://drive.google.com/file/d/10OYzAzj0IpMa0lZ1ZncmQarOCq0_ecmd/view?usp=sharing]]|
**使用方法 [#j0e34d91]
※Android Studioの場合です
app/libs配下に配置
app/build.gradleに以下を追加
dependencies {
implementation files('libs/IDchaLibrary.jar')
}
コードの例:
import jp.co.benesse.dcha.dchaservice.IDchaService;
import jp.co.benesse.dcha.dchautilservice.IDchaUtilService;
public class MainActivity extends Activity {
private IDchaService mDchaService;
private IDchaUtilService mIDchaUtilService;
final string DCHA_SERVICE = "jp.co.benesse.dcha.dchaservice.DchaService";
final string PACKAGE_DCHASERVICE = "jp.co.benesse.dcha.dchaservice";
final string DCHA_UTIL_SERVICE = "jp.co.benesse.dcha.dchautilservice.DchaUtilService";
final string PACKAGE_DCHA_UTIL_SERVICE = "jp.co.benesse.dcha.dchautilservice";
public boolean bindDchaService(int flag, int dchaMode) {
Intent intent = new Intent();
if (dchaMode == 1) {
intent = new Intent(DCHA_SERVICE);
intent.setPackage(PACKAGE_DCHASERVICE);
} else if (dchaMode == 2) {
intent = new Intent(DCHA_UTIL_SERVICE);
intent.setPackage(PACKAGE_DCHA_UTIL_SERVICE);
}
return !bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder iBinder) {
if (dchaMode == 1) {
mDchaService = IDchaService.Stub.asInterface(iBinder);
try {
/* 処理が複数ある場合ここでは変数flagの値でmDchaService,~の処理を決める */
mDchaService.~
} catch (RemoteException ignored) {
}
} else if (dchaMode == 2) {
mIDchaUtilService = IDchaUtilService.Stub.asInterface(iBinder);
try {
/* 処理が複数ある場合ここでは変数flagの値でmDchaUtilService,~の処理を決める */
mIDchaUtilService.~
} catch (RemoteException ignored) {
}
}
unbindService(this);
}
@Override
public void onServiceDisconnected(ComponentName name) {
unbindService(this);
}
}, Context.BIND_AUTO_CREATE);
}
}
Created by Kobold831