package com.yl.aidl1;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.yl.aidl2.QueryData;
public class MainActivity extends AppCompatActivity {
private EditText ed = null;
private Button btn = null;
private TextView data = null;
private QueryData queryData = null;
private ServiceConnection conn = new QueryServiceConnection();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed = findViewById(R.id.ed);
btn = findViewById(R.id.btn);
data = findViewById(R.id.data);
Intent intent = new Intent("com.yl.aidltest");
intent.setPackage("com.yl.aidl2");//要跳转的包名
bindService(intent, conn, BIND_AUTO_CREATE);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String str = ed.getText().toString().trim();
int num = Integer.parseInt(str);
query(num);
}
});
}
private void query(int num) {
Log.e("TAG", num + "");
try {
String str = queryData.QueryListData(num);
data.setText(str);
} catch (Exception e) {
e.printStackTrace();
data.setText("异常报错");
}
}
public final class QueryServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
queryData = QueryData.Stub.asInterface(service);
Log.e("TAG", queryData.toString());
}
@Override
public void onServiceDisconnected(ComponentName name) {
queryData = null;
}
}
@Override
protected void onDestroy() {
unbindService(conn);
super.onDestroy();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
AIDL使用demo实例代码
共226个文件
xml:132个
png:20个
bin:16个
需积分: 14 1 下载量 143 浏览量
2022-11-26
18:21:08
上传
评论
收藏 310KB 7Z 举报
温馨提示
AIDL使用demo实例代码
资源推荐
资源详情
资源评论
收起资源包目录
AIDL使用demo实例代码 (226个子文件)
QueryData.aidl 101B
QueryData.aidl 101B
gradlew.bat 2KB
gradlew.bat 2KB
executionHistory.bin 796KB
executionHistory.bin 778KB
jarAnalysis.bin 320KB
jarAnalysis.bin 244KB
classAnalysis.bin 136KB
classAnalysis.bin 113KB
fileHashes.bin 68KB
fileHashes.bin 68KB
taskHistory.bin 29KB
taskHistory.bin 29KB
outputFiles.bin 22KB
outputFiles.bin 20KB
resourceHashesCache.bin 18KB
resourceHashesCache.bin 18KB
last-build.bin 1B
last-build.bin 1B
.gitignore 240B
.gitignore 240B
.gitignore 50B
.gitignore 50B
.gitignore 6B
.gitignore 6B
build.gradle 1KB
build.gradle 1KB
build.gradle 637B
build.gradle 637B
settings.gradle 44B
settings.gradle 44B
gradlew 5KB
gradlew 5KB
Aidl1.app.iml 9KB
Aidl2.app.iml 9KB
Aidl1.iml 1022B
Aidl2.iml 1022B
gradle-wrapper.jar 53KB
gradle-wrapper.jar 53KB
MainActivity.java 2KB
MainActivity.java 2KB
ExampleInstrumentedTest.java 763B
ExampleInstrumentedTest.java 763B
QueryService.java 617B
ExampleUnitTest.java 389B
ExampleUnitTest.java 389B
MyApp.java 369B
buildOutputCleanup.lock 17B
checksums.lock 17B
fileHashes.lock 17B
javaCompile.lock 17B
executionHistory.lock 17B
buildOutputCleanup.lock 17B
checksums.lock 17B
executionHistory.lock 17B
fileHashes.lock 17B
javaCompile.lock 17B
ic_launcher_round.png 16KB
ic_launcher_round.png 16KB
ic_launcher_round.png 12KB
ic_launcher_round.png 12KB
ic_launcher.png 10KB
ic_launcher.png 10KB
ic_launcher.png 8KB
ic_launcher.png 8KB
ic_launcher_round.png 7KB
ic_launcher_round.png 7KB
ic_launcher_round.png 5KB
ic_launcher_round.png 5KB
ic_launcher.png 5KB
ic_launcher.png 5KB
ic_launcher.png 4KB
ic_launcher.png 4KB
ic_launcher_round.png 3KB
ic_launcher_round.png 3KB
ic_launcher.png 3KB
ic_launcher.png 3KB
proguard-rules.pro 770B
proguard-rules.pro 770B
gradle.properties 1019B
gradle.properties 1019B
local.properties 431B
local.properties 431B
gradle-wrapper.properties 238B
gradle-wrapper.properties 238B
cache.properties 53B
cache.properties 53B
gc.properties 0B
gc.properties 0B
gc.properties 0B
gc.properties 0B
gc.properties 0B
gc.properties 0B
workspace.xml 8KB
workspace.xml 8KB
ic_launcher_background.xml 6KB
ic_launcher_background.xml 6KB
Project.xml 4KB
Project.xml 4KB
共 226 条
- 1
- 2
- 3
资源评论
错误的马蹄声
- 粉丝: 4
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功