3

私はオンラインラジオアプリケーションを開発しています。アプリケーションはバックグラウンドで動作します。NotificationManager をクリックすると、radioclass が再び機能し始めます。実行中のラジオクラスを呼び出したい。どのようにできるのか?

player = MediaPlayer.create(this, Uri.parse("http://...../playlist.m3u8"));
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
            player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer player) {

                }
            });
            player.start();



final int notificationID = 1234;
        String msg = "mesajjj";
        Log.d(TAG, "Preparing to update notification...: " + msg);

        NotificationManager mNotificationManager = (NotificationManager) this
                .getSystemService(Context.NOTIFICATION_SERVICE);



        Intent intent = new Intent(this, RadioClass.class);

// ここで RadioClass が再び実行されます。しかし、RadioClass は既に実行されています。実行中の RadioClass を呼び出す必要があります。

        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);


    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this).setSmallIcon(R.drawable.logotam)
                .setContentTitle("Test FM")
                .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
                .setContentText(msg);

        mBuilder.setContentIntent(pendingIntent);
        mNotificationManager.notify(notificationID, mBuilder.build());
4

1 に答える 1