2016-12-30 37 views
0

我有一個三星Galaxy S6運行Android版本6.0.1,我在Android開發人員文檔中的示例中添加一個內聯回覆操作到我的通知。但不僅僅是它不適用於我,我不知道如何將鍵盤類型更改爲內聯響應的numberDecimal。爲什麼我無法將文本輸入添加到通知中,以及如何設置鍵盤類型?

而不是我的通知中的內嵌文本框,我看到一個正常的圖標和相應的標籤附加在通知的正常內容下面。以下是我已經試過:

Intent actualAmountIntent = new Intent(context, ActualAmountReceiver.class); 
actualAmountIntent.putExtra("expenseId", expense.id); 
PendingIntent actualAmountPendingIntent = PendingIntent.getBroadcast(context, 0, actualAmountIntent, 0); 
RemoteInput remoteInput = new RemoteInput.Builder(ActualAmountReceiver.ACTUAL_AMOUNT_KEY) 
     .setLabel(context.getString(R.string.actual_amount)) 
     .build(); 
Notification.Action action = 
    new Notification.Action.Builder(Icon.createWithResource(context, R.drawable.add_icon), 
     context.getString(R.string.actual_amount), actualAmountPendingIntent) 
      .addRemoteInput(remoteInput) 
      .build(); 
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
Notification.Builder builder = new Notification.Builder(context) 
    .setContentTitle(expense.name) 
    .setContentText(context.getString(R.string.scheduled_expense_notification)) 
    .setAutoCancel(true) 
    .setSmallIcon(R.drawable.my_app_icon) 
    .addAction(action) 
    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); 
notificationManager.notify((int)expense.id, builder.build()); 

ActualAmountReceiver.java:

package my.app.package; 

import android.content.BroadcastReceiver; 
import android.content.Context; 
import android.content.Intent; 

public class ActualAmountReceiver extends BroadcastReceiver { 
    public static final String ACTUAL_AMOUNT_KEY = "actualAmount"; 

    MyDbHelper dbHelper; 

    public void onReceive(Context context, Intent intent) { 
     dbHelper = new MyDbHelper(context); 
     Expense scheduledExpense = dbHelper.getExpense(intent.getLongExtra("expenseId", -1L)); 
     Float actualAmount = intent.getFloatExtra(ACTUAL_AMOUNT_KEY, -1.0f); 

     System.out.println("actual amount received id(" + scheduledExpense.id + ") " + 
          "name(" + scheduledExpense.name + ") " + 
          "type(" + scheduledExpense.type + ") " + 
          "amount(" + amount + ")"); 

     dbHelper.close(); 
    } 
} 

回答

0

在線回覆適用於Android 7.0牛軋糖。正如你所提到的,你的設備中有棉花糖,它將無法工作。

+0

真的嗎?啊,好的,那是有道理的。但是我可以通過6.01版的三星messenger應用程序的通知回覆短信,那麼是否有另一種6.0.1的方式呢? – SnoopDougg

+0

也許他們正在使用一個片段?片段可以製作成類似於通知嗎?例如,用戶可以點擊我的通知,然後內容意圖會在屏幕的頂部打開一個片段,使其看起來像通知已擴展... – SnoopDougg

+0

如果我說得對,您的意思是它會關閉通知面板和彈出片段將像WhatsApp應用程序在Nougat下面一樣打開。然後它是可以實現的。 –

相關問題