我需要从键盘锁(锁定屏幕)控制媒体播放器应用程序。
但我不知道如何。
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());
}
我认为android对于通知键盘锁具有这样的简单功能。