当前位置:网站首页>启动服务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");
}
}边栏推荐
- Solution to network access packet loss of Tencent cloud international ECS
- Hot fix sophix multi-channel patch solution
- iNFTnews | 国内NFT发展仅限于数字藏品吗?
- Jar package merging using Apache ant
- Scala template method pattern
- Usage of assert
- Meta & Berkeley proposed a universal multi-scale visual transformer based on pooled self attention mechanism. The classification accuracy in Imagenet reached 88.8%! Open source
- 腾讯云国际云服务器网络访问丢包问题解决办法
- 【微服务|Sentinel】Sentinel快速入门|构建镜像|启动控制台
- Encryption and encoding resolution
猜你喜欢

Activity startup process

Meta & Berkeley proposed a universal multi-scale visual transformer based on pooled self attention mechanism. The classification accuracy in Imagenet reached 88.8%! Open source

108页(4万字)未来公寓智能化设计平台项目方案建议书2022版

2022 crane driver (limited to bridge crane) examination question bank simulated examination platform operation

Unimportant tokens can be stopped in advance! NVIDIA proposes an efficient visual transformer network a-vit with adaptive token to improve the throughput of the model

Technologie des fenêtres coulissantes en octets dans la couche de transmission

2021-11-07

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

百公里加速仅5.92秒,威兰达高性能版以高能产品实力领跑

Network request -volley
随机推荐
Several ways for wechat applet to jump to the page are worth collecting
【微服务|Sentinel】簇点链路|微服务集群环境搭建
Xcode preview displays a bug in the content of the list view and its solution
iNFTnews | 国内NFT发展仅限于数字藏品吗?
Hot fix sophix multi-channel patch solution
2022R1快开门式压力容器操作考题及答案
2021-11-05
The problem of multiple callback of video ads stimulated by applets (offcolse problem)
Mobile security tool apktool
A website for programmers with a monthly salary of 30K
Practical operation notes - notebook plus memory and ash cleaning
Use of JMeter easynmon
The drawableleft of the custom textview in kotlin is displayed in the center together with the text
Golang示例续期锁:Redis+Channel+sync.Mutex
[redis realizes seckill service ②] solution to oversold problem
断言(assert)的用法
Introduction to smart contract security audit delegatecall (2)
2022熔化焊接与热切割复训题库模拟考试平台操作
实现mnist手写数字识别
2021-02-15