占位的兑现和间接实现从快捷建中启动一个服务
占位的实现和间接实现从快捷建中启动一个服务
1. 占位富大家都很熟悉,但是在android中没有提供,可是有时候我们想一个部分空着 但是又不让被发现
那么就使用
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/login_EditText_password" android:orientation="horizontal"> <View android:layout_width="0dip" android:layout_height="0dip" android:layout_weight="1" /> <Button android:text="@string/login_login" android:id="@+id/login_Button_login" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout>
view就是用来占位的啊。
2. 因为不能从快捷键启动服务 只能间接实行
public class MyServiceActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(this, MyService.class); startService(intent); finish(); } }
也就是说启动一个activity然后在里面启动服务