Android service mechanism

I asked a Android service in a very small one module, is I in activity by startService (service) to start, and I want this software has been running in the background (brother doing an unlock software, always running), so I have not executed stopService (although); I have to code can be run in LogCat, but I still see this:

Ask God: I said in a blog post that to unbind (), but I did not call bindService () method, how to call unbindService () method? ?

Started by Broderick at December 12, 2016 - 7:49 PM

The response to 2013-10-31 08:26:33 was removed by the administrator

Posted by Kitty at December 25, 2016 - 8:48 PM

startService(Intent)Do not need a ServiceConnection object from the log print, you see, how will pop out ServiceConnection ? ?
The Service class code in your overrides the onBind method? The best post some rewriting code

Posted by Mandy at January 03, 2017 - 8:57 PM

Above is the code in my Service

Posted by Broderick at January 09, 2017 - 9:20 PM

private Intent zdLockIntent = null;
private KeyguardManager mKeyguardManager = null;
private static KeyguardManager.KeyguardLock mKeyguardLock = null;
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
Log.i("I'm ZDLockServer onBind "," la la la la la");
return null;

public void onCreate() {
Log.i("I'm ZDLockServer onCreat "," la la la la la");

zdLockIntent = new Intent(ZdLockService.this, MainActivity.class);

mKeyguardManager = (KeyguardManager) this.getSystemService(Context.KEYGUARD_SERVICE);
mKeyguardLock = mKeyguardManager.newKeyguardLock("myNewKeyGuard");
/* Certified broadcast */


public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("I'm ZDLockServer onStartCommand", "intent:" + intent + " flags:" + flags + " startId:" + startId);
// startForeground(startId, null);
return Service.START_STICKY;


public void onDestroy() {
Log.i("I'm ZDLockService onDestroy "," la la la la la");
this.startService(new Intent(ZdLockService.this, ZdLockService.class));

/* Certified broadcast */
private void registerScreenActionReceiver() {
IntentFilter receiverFilter = new IntentFilter();
registerReceiver(mScreenReceiver, receiverFilter);

// The screen lit broadcast, we want to lock screen hidden by default
private BroadcastReceiver mScreenReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.SCREEN_OFF")) {
Toast.makeText(context,"Listening to the black screen",Toast.LENGTH_SHORT).show();
// if (intent.getAction().equals("android.intent.action.CLOSE_SYSTEM_DIALOGS")) {
// Toast.makeText(context,"Listen to the CLOSE_SYSTEM_DIALOGS.",Toast.LENGTH_SHORT).show();
// }

The above is the entire Service

Posted by Broderick at January 13, 2017 - 9:23 PM