プログレスバーと削除ボタンを使用してカスタム通知を作成したいとします。Googleの音楽のようなAndroid 4.0のカスタム通知
スクリーンショット:
私は、プログレスバーとカスタム通知を作成するには成功したが、私は削除イベントを作成するために管理していませんでした。ユーザーが「x」をクリックすると通知をキャンセルしてアップロードを停止したい(googleの音楽のように、通知をクリアするアクティビティを開始したくない)。
ここが私の作業コードです:行
Intent notificationIntent = new Intent(context, UploadEventsReceiver.class);
で
notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
notification = new Notification(icon, tickerText, when);
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(context, UploadEventsReceiver.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.contentView = new RemoteViews(context.getPackageName(), R.layout.upload_progress);
notification.contentView.setOnClickPendingIntent(R.id.text, contentIntent);
notificationManager.notify(this.notificationId, notification);
私は「放送」することなく、放送受信機と試みたが、それを行うための正しい方法かどうかはわかりませんそれと私はそれを機能させるために成功しなかった。何を使用すればいいのですか?
ニース、私はちょうどあなたのスクリーンショットで見つけたものを実装しようとしていましたWiFi、ローテーション、またはフライトモードの場合。あなたはカスタムROMを実行していますか、それともマーケットで見つけましたか?プロジェクトにご協力いただきありがとうございます。 – stfn