如何阅读/解析Tosd邮件,例如usd邮件?

时间:2018-07-06 12:59:58

标签: android toast ussd accessibilityservice

public class UssdListenerService extends AccessibilityService {
    private static final String TAG = "USSDService";

    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {

        if (!(event.getParcelableData() instanceof Notification)) {
            String message = event.getText().toString();
            String sourcePackageName = (String) event.getPackageName();
            long timestamp = Calendar.getInstance().getTimeInMillis();
            Log.e(TAG, "Toast Message" +message + "---" +sourcePackageName + "---" +timestamp);
        }
    }

    @Override
    public void onInterrupt() {
        Log.e(TAG, "Service Interrupt");
    }

    @Override
    protected void onServiceConnected() {

        super.onServiceConnected();
        Log.e(TAG, "onServiceConnected");
        AccessibilityServiceInfo info = new AccessibilityServiceInfo();
        info.flags = AccessibilityServiceInfo.DEFAULT;
        info.packageNames = new String[]{"com.android.phone"};
        info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
        info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
        setServiceInfo(info);
    }
}    

0 个答案:

没有答案