4 Commits
Author SHA1 Message Date
me 1786f03577 changelog, add header for 1.1.2. 2026-10-02 07:20:41 -07:00
me 5b991a5225 main, fix ending bracket. 2026-10-02 07:20:29 -07:00
me 54a0c53c1b Add CHANGELOG. 2026-10-02 07:02:19 -07:00
me 72a77eeef2 alert, begin adding changes to have a foreground service. 2026-10-02 06:54:52 -07:00
4 changed files with 177 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
# Changelog
## 1.2.0 (In Development)
**Add Foreground Service**
- Allow the app to stay in the foreground so that it does not get killed while running.
## 1.1.2 (Sep 28, 2026)
**Fix App Icon**
- Fix and enhance the icon for all versions of Android. Tested to work properly from SDK 16 to 36.
- Changed a few compile time options to help optimize the file size.
- Updated Gradle, AGP, and a few other internals.
## 1.1.1 (Aug 17, 2025)
**Volume Seekbar Fixes**
- Correctly add a space via Java and not Strings.xml.
- Ensure volume seekbar is accurate after app is resumed.
## 1.1.0 (Jul 19, 2025)
**Enhancements**
- Target Android 36 and update theme so that the app may be used properly on current and future versions of Android.
- Volume slider for easy viewing and changing of current settings.
- Add a default sound for devices lacking notification sounds.
- Add a rounded icon.
**Bugfixes**
- App opening with Start already pressed.
- Large intervals (hundreds of hours) causing odd behavior.
## 1.0.6 (Jan 4, 2025)
**Final Production Release**
The release APK available from the Play Store and my website for the last few years.
+8
View File
@@ -14,6 +14,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<service
android:name=".Alert"
android:foregroundServiceType="mediaPlayback"
android:exported="false" />
</application>
</manifest>
@@ -0,0 +1,125 @@
package com.hyperling.apps.infinitetimer;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
public class Alert extends Service {
boolean DEBUG = true;
String TAG = "Alert.", tag;
private static final String CHANNEL_ID = "alert_service_channel";
private static final int NOTIFICATION_ID = 1;
Uri ringtoneUri;
private MediaPlayer mediaPlayer;
private Handler handler = new Handler(Looper.getMainLooper());
private long intervalMs; // user-defined frequency
private final Runnable alertRunnable = new Runnable() {
@Override
public void run() {
playAlert();
handler.postDelayed(this, intervalMs);
}
};
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
tag = TAG + "onStartCommand";
if (intent != null) {
intervalMs = intent.getLongExtra("interval_ms", 5000L);
}
createNotificationChannel();
startForeground(NOTIFICATION_ID, buildNotification());
// Start the alert loop (your original Runnable logic)
handler.post(alertRunnable);
return START_STICKY;
}
private void playAlert() {
// Your existing audio playback code goes here
if (mediaPlayer == null) {
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if (DEBUG) Log.d(tag, "ringtoneUri=" + ringtoneUri.toString());
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying alarm");
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
}
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying ringtone");
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
}
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying all");
ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALL);
mediaPlayer = MediaPlayer.create(this, ringtoneUri);
}
if (mediaPlayer == null) {
if (DEBUG) Log.d(tag, "Media Player is null, trying local sound byte");
mediaPlayer = MediaPlayer.create(this, R.raw.chime_sound_7143);
}
mediaPlayer.seekTo(0);
mediaPlayer.start();
}
}
@Override
public void onDestroy() {
super.onDestroy();
handler.removeCallbacks(alertRunnable);
if (mediaPlayer != null) {
mediaPlayer.release();
mediaPlayer = null;
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
private Notification buildNotification() {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
);
return new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Alert Service Running")
.setContentText("Playing alerts at " + intervalMs + "ms intervals")
.setSmallIcon(R.drawable.ic_notification)
.setOngoing(true)
.setContentIntent(pendingIntent)
.build();
}
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID, "Alert Service", NotificationManager.IMPORTANCE_LOW);
getSystemService(NotificationManager.class)
.createNotificationChannel(channel);
}
}
}
@@ -764,4 +764,5 @@ public class MainActivity extends AppCompatActivity {
return bool;
}
return super.onKeyDown(keyCode, event);
}}
}
}