0

I need control mediaplayer application from keyguard (lock screen).

  • notification playing song
  • play/pause control
  • album image preview

But i don't know how.

public static void putNotification(Context mcontent, String text) {

    Intent resultIntent = new Intent(mcontent, MainActivity.class);

    resultIntent.setAction(Intent.ACTION_MAIN);
    resultIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    PendingIntent resultPendingIntent = PendingIntent.getActivity(mcontent, 0, resultIntent, 0);

    mNotifyManager = (NotificationManager) mcontent.getSystemService(Context.NOTIFICATION_SERVICE);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mcontent);

    mBuilder.setContentTitle(mcontent.getResources().getString(R.string.app_name_inside))
            .setContentText(text)                   
            .setSmallIcon(R.drawable.ic_launcher)   
            .setLargeIcon(bm)                       
            .setTicker(text)                        
            .setAutoCancel(false)                   
            .setOngoing(true)
            .setContentIntent(resultPendingIntent)                  
            .setWhen(System.currentTimeMillis());

    mNotifyManager.notify(0, mBuilder.build());


}

I think android have simple function like this for notify keyguard.

0 Answers0