Android Ï Ä ä¿ öö®HomeHealth» comment '{n' then ° 1 £° Service

Source: Internet
Author: User

Android Ï Ä äö öhomehealth» comment '{n' {° 1 £° Service

» Zookeeper Service has been **é

Service Ç çandroid ******************************************************************** ú úactivity µä¼ %± %²» à £;%µ%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% please refer to the following link for more information: £%%² Ç ?******************************************************** ° U ¶ à ³ ° µ µäzózó Ö öê Ó ózó £ £%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ° Ó ó û § ô ¯ Á áë äë û Activity â ö öö ± ° ò Ì Ð ò Ú i² ¥ £;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ° ó Ì ¨ çâ ¼ äã µrí?å Ï ¢ λ öã µä± äµè £;{×üöö Î n×u Ç ç² Ø Ô ú° órāµä~£.

Service μ ää ¶ ¯ Ó óyangámöööööö½ £ £°Context. startService ()° ÍContext. bindService ()


There are already too many Service providers that have been added to the quota.

Context. startService () implements zookeeper without prior execution of £°

Context. startService ()-> onCreate ()-> onStart ()-> Service running-> context. stopService ()-> onDestroy ()-> Service stop


~%%%Service» {%}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%oncreate () £;è» ° óμ ÷ ó Ã onStart () £»

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Onstart () £;%%%%%%%%%» %öservice %äonstart %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

~~~~Stopservice µä{± ° }» áö± Ó óondestroy £ *********************************************** Í omantömömööø» ózomoto ónó stopService µä» ° £;;service» áò» ö± Ô ú° óró {{%%%%%%%%%%%^ please refer to the following link for more information: Service µäzzomó Ó ó ß Ô Ù stopstopstopstopstopstopstopstop??

Please refer to the following link for more information) --> onDestroy


Context. bindService () implements the same operation as before £°

Context. bindService ()-> onCreate ()-> onBind ()-> Service running-> onUnbind ()-> onDestroy ()-> Service stop

OnBind () when «· μ» Ø ø Ø ¿Í» § ¶ Ë Ò» ö öibind Ó Ú úµ µà {£ibibind Ô Ð í» § ¶ Ë» maid? during» ä äë %² %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%» áquíservice ° óró Ú úres» please visit £;{context í~~öá{£;srevice ~í» áµó ó{onunbind-> onDestroy {à óguí~~ö~£4, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000

Please refer to the following link for more information: {0} </G> <G id = "1"> </G> <G id = "2"> </G> <G id = "2"> onBind </G> ¶ à '{°) --> onUnbind --> onDestory £.

~Úservice has been transferred yet» '************************************************** µó Ó (íâ) £;ä ä{oncreate £;onbind £;onunbind £;ondestory {ú}» ~öéú~üöü~úööð ö» äü±» µ; Ó Ã» '{{£


{0} {0} {0} {0} {0} {0/ authorization/bj2t723qDwvcD4KPHA + signature/Signature + signature + cve-vcd4kpha + signature/Signature/expires/D5sb0tq + 6 zcihz/clusters/Co7o8L3A + CjxwcmUgY2xhc3M9 "brush: java; ">

Layout ² ¼ ¾ öî ä¼ activity _ main. xml


      
   
   
   
  


MainActivity. java 'úâ ~%%â £°

package com.example.hellowendy;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MainActivity extends Activity implements OnClickListener {/** Called when the activity is first created. */Button buttonOn, buttonOff;String TAG = "ServiceActivity";@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);buttonOn = (Button) findViewById(R.id.button_on);buttonOff = (Button) findViewById(R.id.button_off);buttonOn.setOnClickListener(this);buttonOff.setOnClickListener(this);Log.v(TAG, "ActivityonCreate");}@Overridepublic void onClick(View v) {// TODO Auto-generated method stubswitch (v.getId()) {case (R.id.button_on):Log.v(TAG, "ActivitystartService");this.startService(new Intent(this, PlayService.class));// startService(new Intent(this, PlayService.class));break;case (R.id.button_off): {Log.v(TAG, "ActivitystopService");this.stopService(new Intent(this, PlayService.class));// stopService(new Intent(this, PlayService.class));}break;default:break;}}@Overrideprotected void onStop() {// TODO Auto-generated method stubsuper.onStop();Log.v(TAG, "ActivityonStop");}@Overrideprotected void onDestroy() {// TODO Auto-generated method stubLog.v(TAG, "ActivityonDestroy");super.onDestroy();}}


PlayService. java 'úâ ~%%â £°

/** *  *//** * @author Administrator * */package com.example.hellowendy;import java.io.IOException;import android.app.Service;import android.content.Intent;import android.media.MediaPlayer;import android.os.IBinder;import android.util.Log;import android.widget.TextView;import android.widget.Toast;public class PlayService extends Service {String TAG = "ServiceActivity";MediaPlayer mediaPlayer;@Overridepublic IBinder onBind(Intent intent) {// TODO Auto-generated method stubreturn null;}@Overridepublic void onCreate() {// TODO Auto-generated method stubsuper.onCreate();Toast.makeText(this, "Play Service Created", Toast.LENGTH_LONG).show();Log.v(TAG, "ServiceonCreate");//TextView txtview;//txtview = (TextView) findViewById(R.id.txt);//´Ó±¾µØ×ÊÔ´ÖлñÈ¡µÄ¸èÇúcong.mp3, ¡°´Ò´ÒÄÇÄꡱ,cong.mp3Ŀ¼ÊÇhellowendy -> res ->raw -> cong.mp3mediaPlayer = MediaPlayer.create(this, R.raw.cong);
}@Overridepublic void onStart(Intent intent, int startId) {// TODO Auto-generated method stub//super.onStart(intent, startId);//super.onStart();/* * //¿ÉÒÔÔÚOnCreateÀïÃæ´´½¨ÓëÒôÀÖµÄÁ´½Ó£¬Ò²¿ÉÒÔÔÚOnStartÀïÃæ´´½¨ mediaPlayer = * MediaPlayer.create(this, R.raw.test); */Toast.makeText(this, "Play Service onStart", Toast.LENGTH_LONG).show();Log.v(TAG, "ServiceonStart");mediaPlayer.start();}@Overridepublic void onDestroy() {// TODO Auto-generated method stubsuper.onDestroy();Toast.makeText(this, "Play Service Stopped", Toast.LENGTH_LONG).show();Log.v(TAG, "ServiconDestroy");mediaPlayer.stop();}}







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.