android.app.Service.startService()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中android.app.Service.startService()方法的一些代码示例,展示了Service.startService()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Service.startService()方法的具体详情如下:
包路径:android.app.Service
类名称:Service
方法名:startService

Service.startService介绍

暂无

代码示例

代码示例来源:origin: chengbiao1314/android_statistics

@Override
public ComponentName startService(Intent service) {
  Log.v("statistics","Service->startService");
  return super.startService(service);
}

代码示例来源:origin: tyrex-team/senslogs

public void onServiceConnected(ComponentName className,
                IBinder binder) {
  ((KillNotificationsService.KillBinder) binder).service.startService(
      new Intent(mContext, KillNotificationsService.class));
  Intent intent = new Intent(mContext, RecordActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
  PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  NotificationCompat.Builder builder =
      new NotificationCompat.Builder(mContext)
          .setSmallIcon(R.drawable.ic_notification)
          .setContentTitle(mContext.getString(R.string.app_name))
          .setContentText(mContext.getString(R.string.record_notification))
          .setContentIntent(pendingIntent);
  Notification notification = builder.build();
  notification.flags = Notification.FLAG_ONGOING_EVENT;
  NotificationManager mNotificationManager =
      (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
  mNotificationManager.notify(NOTIFICATION_ID, notification);
}

代码示例来源:origin: fennifith/Status

Intent intent = new Intent(AccessibilityService.ACTION_GET_COLOR);
intent.setClass(service, AccessibilityService.class);
service.startService(intent);

相关文章