Service中:
`
public class MyJobService extends JobService {
public static TextView myView;
@Override
public boolean onStartJob(JobParameters params) {
myView = new TextView(this);
myView.setText("在Service中新建");
myView.setTextColor(Color.parseColor("#000000"));
return false;
}
@Override
public boolean onStopJob(JobParameters params) {
return false;
}
}
`
Activity的onCreate中:
`
myView = MyJobService.myView;
if (myView != null) {
((RelativeLayout)findViewById(R.id.activity_main)).addView(myView);
}
`
最终的验证结果是可以正常显示的。