0

アプリを起動したときにステータスバーをクリックすると通知が再起動し、サーバーから音声がストリーミングされ、ステータスバーからクリアされなくなるまで通知が表示されるため、アプリの通知をクリックすると通知が再起動します。アクティビティとストリーミング音楽の停止..通知からアプリの再起動を停止するための解決策を提案してください。アプリを終了するまで通知バーに表示される通知を表示したいです。また、通知に一時停止と再生ボタンを表示したいので、お願いします。それも助けて

public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState); 

        setContentView(R.layout.activity_main);

        nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);

        Intent intent = new Intent(this,MainActivity.class);
        PendingIntent pi= PendingIntent.getActivity(this, 0, in`enter code here`tent, 0);
         String body = " Welcome to streaming ";
         String title = "radio";
         Notification n = new Notification(R.drawable.png, body, System.currentTimeMillis());
         n.setLatestEventInfo(this , title, body, pi);
         n.defaults=Notification.DEFAULT_ALL;
         nm.notify(uniid,n);`
4

1 に答える 1

1

これを、通知を通じて開始しているアクティビティ内のマニフェストファイルに追加します。これは、すでに実行されているかのように、再度再起動されることはありません。

android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden" // fixes orientation

バックプレスでアプリケーションを破棄しないでください:

    @Override
public void onBackPressed()
{
    moveTaskToBack(true);
    //super.onBackPressed();   // comment this line else your app will be destroyed

}
于 2012-08-29T09:10:22.403 に答える