本文整理汇总了Java中android.view.accessibility.AccessibilityEvent.getText方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityEvent.getText方法的具体用法?Java AccessibilityEvent.getText怎么用?Java AccessibilityEvent.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.accessibility.AccessibilityEvent
的用法示例。
在下文中一共展示了AccessibilityEvent.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public boolean onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event) {
if (event.getParcelableData() instanceof Notification) {
Notification notification = (Notification) event.getParcelableData();
Log.d(TAG, "onNotification: " + notification + "; " + event);
onNotification(event, notification);
} else {
List<CharSequence> list = event.getText();
Log.d(TAG, "onNotification: " + list + "; " + event);
if (event.getPackageName().equals(mContext.getPackageName())) {
return false;
}
if (list != null) {
onNotification(event, new NotificationInfo(event.getPackageName(), list));
}
}
return false;
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:19,代码来源:NotificationListener.java
示例2: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType()==AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
List<CharSequence> texts = event.getText();
if (!texts.isEmpty()) {
for (CharSequence text : texts) {
String content = text.toString();
if (content.contains(TIXING)|content.contains(QITA)) {
openNotify(event);
return;
}
}
}
}
openHongBao(event);
}
示例3: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
final boolean result = super.dispatchPopulateAccessibilityEvent(event);
final List<CharSequence> text = event.getText();
text.clear();
// Populate event with a fake title based on the current state.
if (mState == State.APPS) {
text.add(getString(R.string.all_apps_button_label));
} else if (mState == State.WIDGETS) {
text.add(getString(R.string.widget_button_text));
} else if (mWorkspace != null) {
text.add(mWorkspace.getCurrentPageDescription());
} else {
text.add(getString(R.string.all_apps_home_button_label));
}
return result;
}
示例4: onViewTextChanged
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private void onViewTextChanged(AccessibilityEvent event) {
List<CharSequence> text = event.getText();
if (text == null
|| text.size()==0
|| text.get(0).length() == 0
|| event.isPassword()) {
this.mEvent = null;
} else {
onNewText(text.get(0), event);
}
}
示例5: sendNotify
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
public static void sendNotify(AccessibilityEvent event) {
List<CharSequence> texts = event.getText();
if (!texts.isEmpty()) {
String message = texts.get(0).toString();
//过滤微信内部通知消息
if (isInside(message)) {
return;
}
//模拟打开通知栏消息
if (event.getParcelableData() != null && event.getParcelableData() instanceof Notification) {
Log.i("demo", "标题栏canReply=true");
try {
Notification notification = (Notification) event.getParcelableData();
PendingIntent pendingIntent = notification.contentIntent;
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
}
}
示例6: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public boolean onAccessibilityEvent(android.accessibilityservice.AccessibilityService service, AccessibilityEvent event) {
if (event.getParcelableData() instanceof Notification) {
android.app.Notification notification = (android.app.Notification) event.getParcelableData();
Log.d(TAG, "onNotification: " + notification + "; " + event);
onNotification(Notification.create(notification, event.getPackageName().toString()));
} else {
List<CharSequence> list = event.getText();
Log.d(TAG, "onNotification: " + list + "; " + event);
if (event.getPackageName().equals(mContext.getPackageName())) {
return false;
}
if (list != null) {
onToast(event, new Toast(event.getPackageName().toString(), list));
}
}
return false;
}
示例7: monitorNotifications
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
/**
* notification监控
*/
private void monitorNotifications(AccessibilityEvent event) {
if (event.getEventType() != AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) return;
if (event.getText() == null ||
(event.getText().toString() != null && !event.getText().toString().contains(SelfConst.WX_RED_NOTIFICATION_TEXT)))
return;
//模拟点击Notification
if (event.getParcelableData() != null && event.getParcelableData() instanceof Notification) {
Notification notification = (Notification) event.getParcelableData();
try {
notification.contentIntent.send();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例8: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
// Special case to handle window state change events. As far as
// accessibility services are concerned, state changes from
// DrawerLayout invalidate the entire contents of the screen (like
// an Activity or Dialog) and they should announce the title of the
// new content.
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
final List<CharSequence> eventText = event.getText();
final View visibleDrawer = findVisibleDrawer();
if (visibleDrawer != null) {
final int edgeGravity = getDrawerViewAbsoluteGravity(visibleDrawer);
final CharSequence title = getDrawerTitle(edgeGravity);
if (title != null) {
eventText.add(title);
}
}
return true;
}
return super.dispatchPopulateAccessibilityEvent(host, event);
}
示例9: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityEvent event)
{
final int eventType = event.getEventType(); // ClassName:
// com.tencent.mm.ui.LauncherUI
// 通知栏事件
if (eventType == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
{
List<CharSequence> texts = event.getText();
if (!texts.isEmpty())
{
for (CharSequence t : texts)
{
String text = String.valueOf(t);
if (text.contains(WX_HONGBAO_TEXT_KEY) || text.contains(QQ_HONGBAO_TEXT_KEY))
{
openNotify(event);
break;
}
}
}
} else if (eventType == AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE)
{
// 从微信主界面进入聊天界面
openHongBao(event);
} else if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED)
{
// 处理微信聊天界面
openHongBao(event);
}
}
示例10: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityEvent event)
{
SharedPreferences sharedPreferences = getSharedPreferences("nico.styTool_preferences", MODE_PRIVATE);
boolean isFirstRun = sharedPreferences.getBoolean("ok_c", true);
//Editor editor = sharedPreferences.edit();
if (isFirstRun)
{
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setContentTitle("妮媌");
builder.setContentText("QQ抢红包正在运行");
builder.setOngoing(true);
Notification notification = builder.build();
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, notification);
}
else
{
}
if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
{
List<CharSequence> texts = event.getText();
if (!texts.isEmpty())
{
for (CharSequence text : texts)
{
String content = text.toString();
if (content.contains(QQ_KEYWORD_NOTIFICATION))
{
openNotify(event);
return;
}
}
}
}
openHongBao(event);
}
示例11: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
if (event.getEventType() != 32) {
return super.dispatchPopulateAccessibilityEvent(host, event);
}
List<CharSequence> eventText = event.getText();
View visibleDrawer = DrawerLayout.this.findVisibleDrawer();
if (visibleDrawer != null) {
CharSequence title = DrawerLayout.this.getDrawerTitle(DrawerLayout.this.getDrawerViewAbsoluteGravity(visibleDrawer));
if (title != null) {
eventText.add(title);
}
}
return true;
}
示例12: fromEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
public static NotificationInfo fromEvent(AccessibilityEvent event) {
return new NotificationInfo(event.getPackageName(), event.getText());
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:4,代码来源:NotificationListener.java
示例13: getText
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private synchronized void getText(AccessibilityEvent event){
if(XposedEnableUtil.isEnable())
return;
LogUtil.d(TAG,"getText:"+event);
if (!monitorClick || event==null ) {
return;
}
if (showFloatView && !isRun) {
return;
}
int type=getClickType(event);
CharSequence className = event.getClassName();
if (mWindowClassName==null){
return;
}
if (mWindowClassName.toString().startsWith("com.forfan.bigbang")){
//自己的应用不监控
return;
}
if (mCurrentPackage.equals(event.getPackageName())){
if (type!=mCurrentType){
//点击方式不匹配,直接返回
return;
}
}else {
//包名不匹配,直接返回
return;
}
if (className==null || className.equals("android.widget.EditText")){
//输入框不监控
return;
}
if (onlyText){
//onlyText方式下,只获取TextView的内容
if (className==null || !className.equals("android.widget.TextView")){
if (!hasShowTipToast){
ToastUtil.show(R.string.toast_tip_content);
hasShowTipToast=true;
}
return;
}
}
AccessibilityNodeInfo info=event.getSource();
if(info==null){
return;
}
CharSequence txt=info.getText();
if (TextUtils.isEmpty(txt) && !onlyText){
//非onlyText方式下获取文字更多,但是可能并不是想要的文字
//比如系统短信页面需要这样才能获取到内容。
List<CharSequence> txts=event.getText();
if (txts!=null) {
StringBuilder sb=new StringBuilder();
for (CharSequence t : txts) {
sb.append(t);
}
txt=sb.toString();
}
}
if (!TextUtils.isEmpty(txt)) {
if (txt.length()<=2 ){
//对于太短的词进行屏蔽,因为这些词往往是“发送”等功能按钮,其实应该根据不同的activity进行区分
if (!hasShowTooShortToast) {
ToastUtil.show(R.string.too_short_to_split);
hasShowTooShortToast = true;
}
return;
}
Intent intent=new Intent(this, BigBangActivity.class);
intent.addFlags(intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(BigBangActivity.TO_SPLIT_STR,txt.toString());
// startActivity(intent);
//放到ArcTipViewController中触发试试
ArcTipViewController.getInstance().showTipViewForStartActivity(intent);
}
}
示例14: notificationEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
/** 处理通知栏事件 */
private void notificationEvent(AccessibilityEvent event) {
// 小细节, 抢完红包干啥
if(!isRunningForeground(context())){
mAppState = APP_STATE_BACKGROUND;
}else {
mAppState = APP_STATE_FOREGROUND;
}
Parcelable data = event.getParcelableData();
if (data == null || !(data instanceof Notification)) {
return;
}
List<CharSequence> texts = event.getText();
if (!texts.isEmpty()) {
String text = String.valueOf(texts.get(0));
LogUtils.printOut(TAG, text);
int index = text.lastIndexOf(":");
if(index != -1) {
text = text.substring(index + 1);
}
if(text.contains(KEY)) {
isReceived = true;
Notification nf = (Notification) data;
PendingIntent pendingIntent = nf.contentIntent;
if(NotifyUtils.isLockScreen()) { // 是否为锁屏或黑屏状态
if(config().isLockScreenRob()){
NotifyUtils.wakeAndUnlock();
NotifyUtils.send(pendingIntent); // 打开微信
}else{
NotifyUtils.showNotify(context(), String.valueOf(nf.tickerText), pendingIntent); // 显示有红包通知
}
} else {
NotifyUtils.send(pendingIntent); // 打开微信
}
// 播放声音和震动
NotifyUtils.playEffect(context(), config());
}
}
}
示例15: notificationEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
/** 通知栏状态变化 */
private void notificationEvent(AccessibilityEvent event) {
// 小细节, 抢完红包干啥
if(!isRunningForeground(context())){
mAppState = APP_STATE_BACKGROUND;
}else {
mAppState = APP_STATE_FOREGROUND;
}
Parcelable data = event.getParcelableData();
if (data == null || !(data instanceof Notification)) {
return;
}
List<CharSequence> texts = event.getText();
if (!texts.isEmpty()) {
String text = String.valueOf(texts.get(0));
LogUtils.printOut(TAG, text);
int index = text.lastIndexOf(":");
if(index != -1) {
text = text.substring(index + 1);
}
if(text.contains(KEY)) {
isReceived = true;
Notification nf = (Notification) data;
PendingIntent pendingIntent = nf.contentIntent;
if(NotifyUtils.isLockScreen()) { // 是否为锁屏或黑屏状态
if(config().isLockScreenRob()){
NotifyUtils.wakeAndUnlock();
NotifyUtils.send(pendingIntent); // 打开QQ
}else{
NotifyUtils.showNotify(context(), String.valueOf(nf.tickerText), pendingIntent); // 显示有红包通知
}
} else {
NotifyUtils.send(pendingIntent); // 打开QQ
}
// 播放声音和震动
NotifyUtils.playEffect(context(), config());
}
}
}