程序A (包名:com.title)和程序B(包名:)
启动程序B 中的
ActF extends Activity
Thread.sleep(10000);
因为是不同进程,所以此休眠不会影响ActE 的界面相应;点击完之后,立即进入ActF,因为有休眠,Screen只有标题。过了十秒之后才会正常显示。
public class ActE extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button button=new Button(this);
button.setText("ActE go actF");
TextView textView = new TextView(this);
textView.setText(this + " "+this.getTaskId());
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent();
intent.setAction("android.intent.action.View.liuwei");
startActivity(intent);
}
});
LinearLayout layout=new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(button);
this.setContentView(layout);
}
}
启动程序B 中的
ActF extends Activity
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.OtherActivityPro"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".OtherActivityPro"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ActF">
<intent-filter>
<action android:name="android.intent.action.View.liuwei" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" />
</manifest>
public class ActF extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button button=new Button(this);
button.setText("ActF go actD");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView textView = new TextView(this);
textView.setText(this + " "+this.getTaskId());
LinearLayout layout=new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(button);
this.setContentView(layout);
}
}
Thread.sleep(10000);
因为是不同进程,所以此休眠不会影响ActE 的界面相应;点击完之后,立即进入ActF,因为有休眠,Screen只有标题。过了十秒之后才会正常显示。