WEB开发网
开发学院手机开发Android 开发 Android 组件复用和进程关系 阅读

Android 组件复用和进程关系

 2010-09-10 01:06:00 来源:WEB开发网   
核心提示:public void onClick(View v) {Intent intent = new Intent("com.ostrichmyself.tiantian");final ComponentName cn = new ComponentName("com.ostrichmyse

public void onClick(View v) {

Intent intent = new Intent("com.ostrichmyself.tiantian");

final ComponentName cn = new ComponentName("com.ostrichmyself","com.ostrichmyself.ServerActivity");

intent.setComponent(cn);

startActivity(intent);

}

}

}

package com.ostrichmyself;

import android.app.Activity;

import android.content.ComponentName;

import android.content.Intent;

import android.os.Bundle;

import android.os.Process;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.TextView;

public class ServerMainActivity extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

TextView tv = (TextView)findViewById(R.id.mainTV);

ClickAction l = new ClickAction();

tv.setOnClickListener(l);

int myProcessID = Process.myPid();

Log.i("---ServerMainActivity----", myProcessID + "");

}

class ClickAction implements OnClickListener{

public void onClick(View v) {

Intent intent = new Intent("com.ostrichmyself.tiantian");

final ComponentName cn = new ComponentName("com.ostrichmyself","com.ostrichmyself.ServerActivity");

intent.setComponent(cn);

startActivity(intent);

}

}

}

view plaincopy to clipboardprint?

package com.ostrichmyself;

import android.app.Activity;

import android.os.Process;

import android.os.Bundle;

import android.util.Log;

/**

* 这个将被自身和外部调用

上一页  1 2 3 4 5  下一页

Tags:Android 组件 复用

编辑录入:coldstar [复制链接] [打 印]
赞助商链接