当前位置:网站首页>启动服务11111
启动服务11111
2022-06-24 20:17:00 【我与c语言不共戴天】
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="启动服务!"
android:onClick="strat"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>package com.commerce.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void strat(View view) {
Intent intent=new Intent(MainActivity.this,MyService.class);
startService(intent);
}
}My service
package com.commerce.myapplication;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
public class MyService extends Service {
public MyService() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d("test","谢婷正在调用onBin");
return super.onStartCommand(intent, flags, startId);
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
}边栏推荐
- [redis realizes seckill service ④] one order for one person, and cannot be purchased repeatedly
- Syntax highlighting of rich text
- Use of file class filenamefilter & filefilter in io
- 2022R1快开门式压力容器操作考题及答案
- Practical operation notes - notebook plus memory and ash cleaning
- Kibana installation via kubernetes visual interface (rancher)
- Custom animation (simulated win10 loading animation)
- Hot fix sophix multi-channel patch solution
- Scala object blending trait
- Jar package merging using Apache ant
猜你喜欢

iNFTnews | 国内NFT发展仅限于数字藏品吗?

ros(24):error: invalid initialization of reference of type ‘xx’ from expression of type ‘xx’

【微服务|Sentinel】Sentinel快速入门|构建镜像|启动控制台

Custom animation (simulated win10 loading animation)

傳輸層 以字節為單比特的滑動窗口技術

2021-09-12

【微服务|Sentinel】实时监控|RT|吞吐量|并发数|QPS

图书馆管理系统代码源码(php+css+js+mysql) 完整的代码源码

Use of JMeter

2022r1 quick opening pressure vessel operation test questions and answers
随机推荐
Applet opening traffic master
Technologie des fenêtres coulissantes en octets dans la couche de transmission
adb shell sendevent
Helm chart warehouse operation
2022年全国最新消防设施操作员(高级消防设施操作员)模拟题及答案
2021-11-07
QT (36) -rapidjson parsing nested JSON
Encryption and encoding resolution
[redis realizes seckill service ②] solution to oversold problem
EVM简略
Golang示例续期锁:Redis+Channel+sync.Mutex
Can communication experiment between C and C
Text border format and text block of rich text
2022 crane driver (limited to bridge crane) examination question bank simulated examination platform operation
移动安全工具-dex2jar
Punch smart spirit 1. The brand is attractive. What is the strength of the product?
Add information on the left and add parts on the right of the status bar
JS dynamically generates variable names and assigns values
C#和C 的CAN通信实验
QT(36)-rapidjson解析嵌套的json