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

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

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

Service.getString介绍

暂无

代码示例

代码示例来源:origin: Genymobile/gnirehtet

@TargetApi(26)
private void createNotificationChannel() {
  NotificationChannel channel = new NotificationChannel(CHANNEL_ID, context.getString(R.string.app_name), NotificationManager
      .IMPORTANCE_DEFAULT);
  getNotificationManager().createNotificationChannel(channel);
}

代码示例来源:origin: Genymobile/gnirehtet

private Notification createNotification(boolean failure) {
  Notification.Builder notificationBuilder = createNotificationBuilder();
  notificationBuilder.setContentTitle(context.getString(R.string.app_name));
  if (failure) {
    notificationBuilder.setContentText(context.getString(R.string.relay_disconnected));
    notificationBuilder.setSmallIcon(R.drawable.ic_report_problem_24dp);
  } else {
    notificationBuilder.setContentText(context.getString(R.string.relay_connected));
    notificationBuilder.setSmallIcon(R.drawable.ic_usb_24dp);
  }
  notificationBuilder.addAction(createStopAction());
  return notificationBuilder.build();
}

代码示例来源:origin: Genymobile/gnirehtet

private Notification.Action createStopAction() {
  Intent stopIntent = GnirehtetService.createStopIntent(context);
  PendingIntent stopPendingIntent = PendingIntent.getService(context, 0, stopIntent, PendingIntent.FLAG_ONE_SHOT);
  // the non-deprecated constructor is not available in API 21
  @SuppressWarnings("deprecation")
  Notification.Action.Builder actionBuilder = new Notification.Action.Builder(R.drawable.ic_close_24dp, context.getString(R.string.stop_vpn),
      stopPendingIntent);
  return actionBuilder.build();
}

代码示例来源:origin: r3bl-org/stay-awake-app

@NonNull
  private static String getNotificationStopActionText(Service context) {
    return context.getString(R.string.notification_stop_action_text);
  }
} // end class HandleNotifications.

代码示例来源:origin: r3bl-org/stay-awake-app

@NonNull
private static String getNotificationTitle(Service context) {
  return context.getString(R.string.notification_text_title);
}

代码示例来源:origin: r3bl-org/stay-awake-app

@NonNull
private static String getNotificationContent(Service context) {
  return context.getString(R.string.notification_text_content);
}

代码示例来源:origin: xbmc/Kore

private Notification buildNothingPlayingNotification() {
  int smallIcon = R.drawable.ic_devices_white_24dp;
  NotificationCompat.Builder builder = new NotificationCompat.Builder(mService, NOTIFICATION_CHANNEL);
  return builder
      .setSmallIcon(smallIcon)
      .setShowWhen(false)
      .setOngoing(true)
      .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
      .setCategory(NotificationCompat.CATEGORY_TRANSPORT)
      .setContentIntent(mRemoteStartPendingIntent)
      .setContentTitle(String.format(mService.getString(R.string.connected_to),
          HostManager.getInstance(mService).getHostInfo().getName()))
      .setContentText(mService.getString(R.string.nothing_playing))
      .build();
}

代码示例来源:origin: xbmc/Kore

@TargetApi(Build.VERSION_CODES.O)
private void buildNotificationChannel() {
  NotificationChannel channel =
      new NotificationChannel(NOTIFICATION_CHANNEL,
          mService.getString(R.string.app_name),
          NotificationManager.IMPORTANCE_LOW);
  channel.enableLights(false);
  channel.enableVibration(false);
  channel.setShowBadge(false);
  NotificationManager notificationManager =
      (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
  notificationManager.createNotificationChannel(channel);
}

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

private void startForeground(String packageName, AppData.ActivityData activityData) {
  Intent contentIntent = new Intent(service, MainActivity.class);
  contentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  TaskStackBuilder contentStackBuilder = TaskStackBuilder.create(service);
  contentStackBuilder.addParentStack(MainActivity.class);
  contentStackBuilder.addNextIntent(contentIntent);
  NotificationCompat.Builder builder = new NotificationCompat.Builder(service)
      .setSmallIcon(R.drawable.ic_notification)
      .setColor(ContextCompat.getColor(service, R.color.colorAccent))
      .setContentTitle(service.getString(R.string.app_name))
      .setContentText(activityData.name)
      .setSubText(packageName)
      .setContentIntent(contentStackBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT));
  if (PreferenceData.STATUS_COLOR_AUTO.getValue(service)) {
    Intent colorIntent = new Intent(service, AppSettingActivity.class);
    colorIntent.putExtra(AppSettingActivity.EXTRA_COMPONENT, activityData.packageName + "/" + activityData.name);
    colorIntent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    builder.addAction(R.drawable.ic_notification_color, service.getString(R.string.action_set_color), PendingIntent.getActivity(service, 0, colorIntent, PendingIntent.FLAG_CANCEL_CURRENT));
  }
  boolean isFullscreen = activityPreference != null && activityPreference.isFullScreen(service);
  Intent visibleIntent = new Intent(service, ActivityFullScreenSettingReceiver.class);
  visibleIntent.putExtra(ActivityFullScreenSettingReceiver.EXTRA_COMPONENT, activityData.packageName + "/" + activityData.name);
  visibleIntent.putExtra(ActivityFullScreenSettingReceiver.EXTRA_FULLSCREEN, isFullscreen);
  builder.addAction(R.drawable.ic_notification_visible, service.getString(isFullscreen ? R.string.action_show_status : R.string.action_hide_status), PendingIntent.getBroadcast(service, 0, visibleIntent, PendingIntent.FLAG_CANCEL_CURRENT));
  Intent settingsIntent = new Intent(service, AppSettingActivity.class);
  settingsIntent.putExtra(AppSettingActivity.EXTRA_COMPONENT, activityData.packageName);
  settingsIntent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
  builder.addAction(R.drawable.ic_notification_settings, service.getString(R.string.action_app_settings), PendingIntent.getActivity(service, 0, settingsIntent, PendingIntent.FLAG_CANCEL_CURRENT));
  service.startForeground(ID_FOREGROUND, builder.build());
}

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

.setSmallIcon(R.drawable.ic_notification)
.setColor(ContextCompat.getColor(service, R.color.colorAccent))
.setContentTitle(service.getString(R.string.app_name))
.setContentIntent(contentStackBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT))
.build()

代码示例来源:origin: xbmc/Kore

case ListType.ItemsAll.TYPE_EPISODE:
  title = getItemResult.title;
  String seasonEpisode = String.format(mService.getString(R.string.season_episode_abbrev),
                     getItemResult.season, getItemResult.episode);
  underTitle = String.format("%s | %s", getItemResult.showtitle, seasonEpisode);

相关文章