アンドロイド4.0以上のステータスバーに展開と折りたたみの通知を実装する必要があります。私はこのためにGoogleで検索しましたが、誰もが展開と折りたたみの通知を実装するandroid
答えて
拡張Notification
がNotification
Big View
の特殊なケースである。この
は、事前にありがとう実装する方法私のアイデアを持っていない実装のための任意のコードソリューションを取得しませんでした。 Big View
が通知トレイの上部にない場合は、「閉じた」と表示され、スワイプで拡張可能です。 Androidデベロッパーからのお見積もり:
通知が拡大された場合、通知が通知トレイの一番上にあるとき、またはユーザーがジェスチャーを使用して通知を展開した場合にのみ表示されます。拡張された通知は、Android 4.1から利用可能です。次のように
Big View
Notification
を作成することができる。
Notification notification = new Notification.BigTextStyle(builder)
.bigText(myText).build();
又は
Notification notification = new Notification.BigPictureStyle(builder)
.bigPicture(
BitmapFactory.decodeResource(getResources(),
R.drawable.my_picture)).build();
Hereチュートリアルです。
アンドロイド4.1の下に拡張可能な通知を作成することはできません。 しかし、これに代えて、通知を積み重ねることができます。次に、すべての通知をリストに表示するわかりやすいカスタムアクティビティに保留中のインテントを設定することができます。 ユーザーはこれを見て幸せだろう:)
Notification noti = new Notification.Builder()
... // The same notification properties as the others
.setStyle(new Notification.BigPictureStyle().bigPicture(mBitmap))
.build();
あなたがOKの発表とともに
.setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))
を変更!ここで
notification = new NotificationCompat.Builder(context)
は一例です:
Intent intent = new Intent(context, ReserveStatusActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
intent = new Intent(String.valueOf(PushActivity.class));
intent.putExtra("message", MESSAGE);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(PushActivity.class);
stackBuilder.addNextIntent(intent);
// PendingIntent pendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
// android.support.v4.app.NotificationCompat.BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
// bigStyle.bigText((CharSequence) context);
notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(th_title)
.setContentText(th_alert)
.setAutoCancel(true)
// .setStyle(new Notification.BigTextStyle().bigText(th_alert) ตัวเก่า
// .setStyle(new NotificationCompat.BigTextStyle().bigText(th_title))
.setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))
.setContentIntent(pendingIntent)
.setNumber(++numMessages)
.build();
notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificationManager.notify(1000, notification);
または
private void sendNotification(RemoteMessage.Notification notification, Map<String, String> data) {
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
// .setContentTitle(notification.getTitle())
.setContentTitle(getResources().getText(R.string.app_name))
.setContentText(notification.getBody())
.setAutoCancel(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentIntent(pendingIntent)
.setStyle(new NotificationCompat.BigTextStyle().bigText(notification.getBody()))
.setContentInfo(notification.getTitle())
.setLargeIcon(icon)
.setColor(Color.RED)
.setSmallIcon(R.drawable.logo);
try {
String picture_url = data.get("picture_url");
if (picture_url != null && !"".equals(picture_url)) {
URL url = new URL(picture_url);
Bitmap bigPicture = BitmapFactory.decodeStream(url.openConnection().getInputStream());
notificationBuilder.setStyle(
new NotificationCompat.BigPictureStyle().bigPicture(bigPicture).setSummaryText(notification.getBody())
);
}
} catch (IOException e) {
e.printStackTrace();
}
notificationBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
notificationBuilder.setLights(Color.YELLOW, 1000, 300);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
正解と完全な答え、ありがとう! –
私のBigTextは小さく重なっています。これはクリックでは展開されません – TeodorKolev
- 1. (スウィフト)展開と折りたたみテーブルビューセルタップ
- 2. WPFエクスパンダの展開/折りたたみ
- 3. CSSの折りたたみ/展開
- 4. jQueryヘッダーで展開/折りたたみ
- 5. WPF DataBoundツリービュー展開/折りたたみ
- 6. CSS3トランジションの展開/折りたたみを追加する
- 7. 折りたたみを展開するページの検索/検索
- 8. Android:AppCompatライブラリなしのツールバーの展開と折りたたみ
- 9. jQueryの展開と折りたたみのテキスト
- 10. JSF1を使用してレコードビューを展開/折りたたむ - tomahawkの実装
- 11. c#winform:node TreeViewで展開と折りたたみを行う
- 12. Telerik RadTreeViewとクライアント側の展開/折りたたみ
- 13. アドバイス/ブレーンストーンの書き直しと展開/折りたたみボックス
- 14. SSRS 2008 - サブレポートの展開と折りたたみ
- 15. SplitContainerパネルの折りたたみと展開
- 16. Android:プログラムでCollapseingToolbarLayoutを折りたたんで展開する
- 17. PhpStormの展開/折りたたみボタンを隠す
- 18. JQueryと展開/折りたたみ機能
- 19. ノックアウトテーブル/サブテーブルの展開/折りたたみボタンの切り替え
- 20. 別の要素を展開すると要素を折りたたみます。
- 21. チェックボックスがスタックパネルの展開/折りたたみアニメーションをトリガー
- 22. キャプションレイヤーでJQuery jQGridの展開/折りたたみグリッドをクリック
- 23. エディタウィンドウで展開と折りたたみコードのボタンサイズを変更する
- 24. Jqueryのトグル - 複数のdivでの展開/折りたたみ
- 25. html javascriptの折りたたみ/展開テーブルの行、子の行
- 26. Xamarinは、スクロール時にAndroidツールバーを展開/折りたたむ
- 27. ツリービューの展開/折りたたみアイコンのカスタマイズ
- 28. jsTreeノードは展開/折りたたみを行いません。
- 29. ag-grid - ツリーデータの展開/折りたたみ
- 30. GtkTreeViewは、キー押下イベントの展開/折りたたみ
を設定することができます。 'RemoteView'カスタムレイアウト、またはデフォルトの' NotificationBuilder'? –