我已经创建了一个基本的systemd服务文件来启动一个应用程序。该文件如下所示:
[Unit]
Description=Starting a Basic Application
[Service]
ExecStart=/usr/bin/app_linux 0x040000
[Install]
WantedBy=multi-user.target
当我运行systemctl status basic.service
时,我能够看到它正在运行。
我想在dmesg中看到此服务文件的描述。
答案 0 :(得分:0)
将您的服务放在/ etc / systemd / system中,然后将其称为basic.service,现在通过以下命令启用它" systemctl enable basic.service" (这应该创建一个链接ln -s' /etc/systemd/system/basic.service'' /etc/systemd/system/multi-user.target.wants/basic.service' ;),现在重启你的电路板,现在检查你的dmesg输出。您可以更改输出应链接的位置,以便为StandardOutput选项引用link。
public class MainActivity extends AppCompatActivity {
ExpandableListView ev_list;
List> lv_country = new ArrayList<>();
CustomAdapter customAdapter;
EditText et_search;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
init();
}
private void init() {
ev_list = (ExpandableListView) findViewById(R.id.ev_list);
et_search = (EditText) findViewById(R.id.et_search);
fn_arraylist();
customAdapter = new CustomAdapter(lv_country, getApplicationContext());
ev_list.setAdapter(customAdapter);
ev_list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
return true; // This way the expander cannot be collapsed
}
});
for (int i = 0; i < customAdapter.getGroupCount(); i++) {
ev_list.expandGroup(i);
}
et_search.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (et_search.getText().toString().length() == 0) {
customAdapter = new CustomAdapter(lv_country, getApplicationContext());
ev_list.setAdapter(customAdapter);
for (int i = 0; i < customAdapter.getGroupCount(); i++) {
ev_list.expandGroup(i);
}
} else {
List> lv_search = new ArrayList<>();
for (int i = 0; i < lv_country.size(); i++) {
List> lv_searchstate = new ArrayList<>();
List> lv_state = (List>) lv_country.get(i).get("State");
for (int j = 0; j < lv_state.size(); j++) {
if (lv_state.get(j).get("Name").toString().toLowerCase().contains(et_search.getText().toString())) {
lv_searchstate.add(lv_state.get(j));
}
}
if (lv_searchstate.size() != 0) {
HashMap hashMap_search = new HashMap<>();
hashMap_search.put("Name", lv_country.get(i).get("Name").toString());
hashMap_search.put("State", lv_searchstate);
lv_search.add(hashMap_search);
}
}
customAdapter = new CustomAdapter(lv_search, getApplicationContext());
ev_list.setAdapter(customAdapter);
for (int i = 0; i < customAdapter.getGroupCount(); i++) {
ev_list.expandGroup(i);
}
}
}
});
}
答案 1 :(得分:-2)
After copying my service file to "/etc/systemd/system/basic.service"
[Unit]
Desciption=Starting a Basic Application
DefaultDependencies=no
[Service]
Type=idle
ExecStart=/usr/bin/app_linux 0x40000
ExecStop=/usr/bin/killall app_linux
rebooted and i am able to see message in dmesg