你會發現,你不能,如果單擊發送檢測狀態或者只要你閱讀相應的源代碼取消。
「將短信發送到短信短信代碼(或疑似短信短信號碼)的默認行爲是要求用戶確認。使用戶可以將默認策略(」記住此選擇「複選框)設置爲總是/永遠不允許應用程序在將來發送短信至優質短代碼。策略可以通過應用程序信息屏幕中的設置應用程序進行更改。「 See here for details
該對話框中 SRC/JAVA/COM /機器人/內部/電話/ SMSDispatcher.java
/**
* Post an alert when SMS needs confirmation due to excessive usage.
* @param tracker an SmsTracker for the current message.
*/
protected void handleReachSentLimit(SmsTracker tracker) {
if (denyIfQueueLimitReached(tracker)) {
return; // queue limit reached; error was returned to caller
}
CharSequence appLabel = getAppLabel(tracker.mAppInfo.packageName);
Resources r = Resources.getSystem();
Spanned messageText = Html.fromHtml(r.getString(R.string.sms_control_message, appLabel));
ConfirmDialogListener listener = new ConfirmDialogListener(tracker);
AlertDialog d = new AlertDialog.Builder(mContext)
.setTitle(R.string.sms_control_title)
.setIcon(R.drawable.stat_sys_warning)
.setMessage(messageText)
.setPositiveButton(r.getString(R.string.sms_control_yes), listener)
.setNegativeButton(r.getString(R.string.sms_control_no), listener)
.setOnCancelListener(listener)
.create();
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
d.show();
}
和負和正按鈕的回調定義:
/**
* Dialog listener for SMS confirmation dialog.
*/
private final class ConfirmDialogListener
implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener,
CompoundButton.OnCheckedChangeListener {
private final SmsTracker mTracker;
private Button mPositiveButton;
private Button mNegativeButton;
private boolean mRememberChoice; // default is unchecked
ConfirmDialogListener(SmsTracker tracker) {
mTracker = tracker;
}
void setPositiveButton(Button button) {
mPositiveButton = button;
}
void setNegativeButton(Button button) {
mNegativeButton = button;
}
@Override
public void onClick(DialogInterface dialog, int which) {
// Always set the SMS permission so that Settings will show a permission setting
// for the app (it won't be shown until after the app tries to send to a short code).
int newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER;
if (which == DialogInterface.BUTTON_POSITIVE) {
Log.d(TAG, "CONFIRM sending SMS");
// XXX this is lossy- apps can have more than one signature
EventLog.writeEvent(EventLogTags.SMS_SENT_BY_USER,
mTracker.mAppInfo.signatures[0].toCharsString());
sendMessage(obtainMessage(EVENT_SEND_CONFIRMED_SMS, mTracker));
if (mRememberChoice) {
newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW;
}
} else if (which == DialogInterface.BUTTON_NEGATIVE) {
Log.d(TAG, "DENY sending SMS");
// XXX this is lossy- apps can have more than one signature
EventLog.writeEvent(EventLogTags.SMS_DENIED_BY_USER,
mTracker.mAppInfo.signatures[0].toCharsString());
sendMessage(obtainMessage(EVENT_STOP_SENDING, mTracker));
if (mRememberChoice) {
newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW;
}
}
setPremiumSmsPermission(mTracker.mAppInfo.packageName, newSmsPermission);
}
當您單擊對話框上的發送或取消按鈕時,它將在其線程中向其處理程序發送消息。但似乎沒有辦法讓您捕獲點擊事件。
是否它會自動發送消息,如果你點擊發送? –
是的,它不是自動的,但我如何檢測,如果點擊發送要知道發送短信或取消dimis此對話框 –
這個對話框由你編碼?或者它是自動來的? –