当前位置:网站首页>启动服务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"); } }
边栏推荐
- Qiniu cloud uploads video to get the first frame of video
- How to quickly open traffic master for wechat applet
- Using tcp/udp tools to debug the yeelight ribbon
- The problem of multiple callback of video ads stimulated by applets (offcolse problem)
- Hot fix sophix multi-channel patch solution
- If the order has not been paid for 30 minutes, it will be automatically cancelled. How can I achieve this?
- 热力图展示相关矩阵
- Technologie des fenêtres coulissantes en octets dans la couche de transmission
- 2021-04-18
- [microservices sentinel] cluster link | microservices cluster environment construction
猜你喜欢
iNFTnews | 国内NFT发展仅限于数字藏品吗?
2022 crane driver (limited to bridge crane) examination question bank simulated examination platform operation
51 single chip microcomputer multi computer communication
Practical operation notes - notebook plus memory and ash cleaning
[microservices sentinel] sentinel quick start | building an image | starting the console
QT electronic clock
【Redis实现秒杀业务②】超卖问题的解决方案
108页(4万字)未来公寓智能化设计平台项目方案建议书2022版
How to reduce the font size of custom controls (optimize the round dot progress bar)
移动安全工具-jar
随机推荐
我想问一下兴业证券怎么开户?通过链接办理股票开户安全吗
Introduction to smart contract security audit delegatecall (2)
In the process of enterprise development, I found that a colleague used the select * from where condition for update
Leetcode 1248. 统计「优美子数组」(害,突然发现只会暴力枚举了)
ros(24):error: invalid initialization of reference of type ‘xx’ from expression of type ‘xx’
Paint rounded rectangle
Examination questions and mock examination for safety management personnel of hazardous chemical business units in 2022
QT(35)-操作EXCEL-QXlsx-QAxObject
108页(4万字)未来公寓智能化设计平台项目方案建议书2022版
Single blind box removal, social blind box and friend blind box program source code
108 pages (40000 words) proposal for future apartment intelligent design platform project (version 2022)
EVM简略
C#和C 的CAN通信实验
Hot fix sophix multi-channel patch solution
百公里加速仅5.92秒,威兰达高性能版以高能产品实力领跑
A plug-in framework for implementing registration free and login verification with hook technology
Jar package merging using Apache ant
Leetcode 1248. Statistics of "graceful subarray" (harm, suddenly found that it can only enumerate violently)
How to quickly open traffic master for wechat applet
Tiktok wallpaper applet v1.0.2 function, new arrival function