zoukankan      html  css  js  c++  java
  • AIDL

    ServiceConnection conn = new ServiceConnection() {
    	
    	@Override
    	public void onServiceDisconnected(ComponentName name) {
    		// TODO Auto-generated method stub
    		
    	}
    	
    	@Override
    	public void onServiceConnected(ComponentName name, IBinder service) {
    		appleService = IApple.Stub.asInterface(service);
    		
    	}
    };
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    		color = (EditText) findViewById(R.id.color);
    		weight = (EditText) findViewById(R.id.weight);
    		get = (Button) findViewById(R.id.get);
    		Intent intent = new Intent();
    		intent.setAction("AIDLSERVICETEST");
    		//绑定到远程服务上
    		bindService(intent, conn, Service.BIND_AUTO_CREATE);
    		get.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				try {
    					color.setText(appleService.getColor());
    					weight.setText(appleService.getWeight()+"");
    				} catch (RemoteException e) {
    					// TODO Auto-generated catch block
    					e.printStackTrace();
    				}
    			}
    		});
    	}
    	@Override
    	protected void onDestroy() {
    		// TODO Auto-generated method stub
    		unbindService(conn);
    		super.onDestroy();
    	}
    
    }

  • 相关阅读:
    差分约束+SPFA+栈
    差分约束问题讲解博客
    最小费用最大流2
    最小费用最大流
    合并油田
    PHP核心技术与最佳实践--笔记
    PHP命令行模式
    vim一些常用的快捷键
    varnish 的一个配置
    redis在我工作中的实际应用
  • 原文地址:https://www.cnblogs.com/allencoder/p/3643916.html
Copyright © 2011-2022 走看看