开发学院手机开发Android 开发 Android 实例展现如何不同程序间的Serivce调用 阅读

Android 实例展现如何不同程序间的Serivce调用

 2010-09-15 00:10:00 来源:WEB开发网   
核心提示:import android.content.ServiceConnection;import android.os.Bundle;import android.os.IBinder;import android.os.RemoteException;import android.util.Log;import and

import android.content.ServiceConnection;

import android.os.Bundle;

import android.os.IBinder;

import android.os.RemoteException;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

public class ServiceActivity extends Activity {

private EditText ev1;

private EditText ev2;

private Button bstart;

private Button bstop;

private Button bget;

private Button bset;

private TextView tv;

private IDemoServiceBinder dsb;

private ServiceConnection sc = new ServiceConnection() {

@Override

public void onServiceConnected(ComponentName name, IBinder service) {

Log.d("ServiceActivity", "onServiceConnected");

dsb = IDemoServiceBinder.Stub.asInterface(service);

}

@Override

public void onServiceDisconnected(ComponentName name) {

Log.d("ServiceActivity", "onServiceDisconnected");

dsb = null;

}

};

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

ev1 = (EditText) findViewById(R.id.EditText01);

ev2 = (EditText) findViewById(R.id.EditText02);

bstart = (Button) findViewById(R.id.b_start);

bstop = (Button) findViewById(R.id.b_stop);

bstart.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

// Intent demoService = new Intent(ServiceActivity.this,

// DemoService.class);

Intent demoService2 = new Intent("com.shinestudio.demo.demoservice");

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android 实例 展现

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接