Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Commit

Permalink
Love Track in Notification
Browse files Browse the repository at this point in the history
  • Loading branch information
stduser committed Feb 4, 2017
1 parent 87136dc commit af6d0dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Expand Up @@ -24,7 +24,6 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.nfc.Tag;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
Expand Down
Expand Up @@ -53,6 +53,7 @@ public int onStartCommand(Intent i, int flags, int startId) {
.setContentTitle("")
.setSmallIcon(R.mipmap.ic_notify)
.setContentText("")
.setPriority(NotificationCompat.PRIORITY_MIN)
.setContentIntent(contentIntent);

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/adam/aslfms/service/ScrobblingService.java
Expand Up @@ -93,13 +93,22 @@ public void onCreate() {
String tr = mCurrentTrack.getTrack();
String api = mCurrentTrack.getMusicAPI().readAPIname();

// Heart intent
Intent heartIntent = new Intent(mCtx, ScrobblingService.class);
heartIntent.setAction(ScrobblingService.ACTION_HEART);
PendingIntent heartPendingIntent = PendingIntent.getService(mCtx, 0, heartIntent, 0);
NotificationCompat.Action heartAction = new NotificationCompat.Action.Builder(R.mipmap.ic_status_wail_love_track, "", heartPendingIntent).build();


Intent targetIntent = new Intent(mCtx, SettingsActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(mCtx, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(mCtx)
.setContentTitle(tr)
.setSmallIcon(R.mipmap.ic_notify)
.setContentText(ar + " :" + api)
.setPriority(NotificationCompat.PRIORITY_MIN)
.addAction(heartAction)
.setContentIntent(contentIntent);

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
Expand Down Expand Up @@ -133,13 +142,21 @@ public int onStartCommand(Intent i, int flags, int startId) {
String tr = mCurrentTrack.getTrack();
String api = mCurrentTrack.getMusicAPI().readAPIname();

// Heart intent
Intent heartIntent = new Intent(mCtx, ScrobblingService.class);
heartIntent.setAction(ScrobblingService.ACTION_HEART);
PendingIntent heartPendingIntent = PendingIntent.getService(mCtx, 0, heartIntent, 0);
NotificationCompat.Action heartAction = new NotificationCompat.Action.Builder(R.mipmap.ic_status_wail_love_track, "", heartPendingIntent).build();

Intent targetIntent = new Intent(mCtx, SettingsActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(mCtx, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(mCtx)
.setContentTitle(tr)
.setSmallIcon(R.mipmap.ic_notify)
.setContentText(ar + " :" + api)
.setPriority(NotificationCompat.PRIORITY_MIN)
.addAction(heartAction)
.setContentIntent(contentIntent);

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
Expand Down

0 comments on commit af6d0dc

Please sign in to comment.