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.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;
/**
* 这个将被自身和外部调用
更多精彩
赞助商链接