Android服务监控

我只贴了关键代码,其实就是import android.telephony.ServiceState

ServiceState ss=new ServiceState();

                int s;

                s=ss.getState();

                switch(s)

                {

                case ServiceState.STATE_EMERGENCY_ONLY:

                	Toast toast1=Toast.makeText(GSMDetector.this,"Emegency_only", Toast.LENGTH_SHORT);

                	toast1.show();

                	break;

                case ServiceState.STATE_IN_SERVICE:

                	Toast toast2=Toast.makeText(GSMDetector.this,"in_Service", Toast.LENGTH_SHORT);

                	toast2.show();

                	break;

                case ServiceState.STATE_OUT_OF_SERVICE:

                	Toast toast3=Toast.makeText(GSMDetector.this,"out_of_Service", Toast.LENGTH_SHORT);

                	toast3.show();

                	break;

                case ServiceState.STATE_POWER_OFF:

                	Toast toast4=Toast.makeText(GSMDetector.this,"Power_off", Toast.LENGTH_SHORT);

                	toast4.show();

                	break;

你可能感兴趣的:(android)