0

I would like to get back results in a variable of type String. The contents of what the user tells his smartphone via Google now that is: "OK google claptrap " I would like to do this so I could get back 'claptrap'. I have already searched but have been unsuccessful. I found how to return my selectable application in Google now like, for example write a note in my app but in this case the person has to say " OK google note at me claptrap " so that I can get back claptrap. It is not proceeding well … I am pretty sure that it is possible because the app "commandr" already makes it for commands as "turn on the torch".

Excuse my bad english.

Thank you in advance Good evening :D


i have create a AccessibilityService for get command google now but i should touch editText for receive the command. Help me please

public class NotificationService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    System.out.println("******onAccessibilityEvent*******");
    if(event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED || event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED) {
        System.out.println(" NAME : " + event.getClassName());
        System.out.println(" NAME PCK : " + event.getPackageName());
        System.out.println(" SOURCE : " + event.getSource());
        System.out.println(" TEXT : " + event.getText());
    }
}

private String RecupCommandGoogle(AccessibilityEvent mEvent, AccessibilityNodeInfo mSource) {
    if (mSource != null & mEvent.getClassName().equals("android.view.View")) {
        return String.valueOf(mSource.performAction(AccessibilityNodeInfo.ACTION_SELECT));
    }
    return null;
}

@Override
protected void onServiceConnected() {
    System.out.println("onServiceConnected");
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPE_WINDOWS_CHANGED | AccessibilityEvent.TYPE_VIEW_FOCUSED ;
    info.packageNames = new String[] {"com.google.android.launcher" , "com.google.android.googlequicksearchbox"};
    info.feedbackType = AccessibilityEvent.TYPES_ALL_MASK;
    info.notificationTimeout = 100;
    setServiceInfo(info);
}

@Override
public void onInterrupt() {
    System.out.println("onInterrupt");
}

}

Undo
  • 25,519
  • 37
  • 106
  • 129
Ne0ratek
  • 1
  • 1
  • I'm confused, what is your exact question? I seem to get faster, better, and more answers when I [include just a little snippet of code](http://stackoverflow.com/help/mcve). probably because it is much easier for others to copy/paste/modify rather than writing an example from scratch, and programmers can more generally read the code to quickly see the problem regardless of what language in which the question was written. – Jeff Puckett May 15 '16 at 18:04
  • I'm not so sure. But take a look at this. https://developers.google.com/voice-actions/system/ it might help :) – KISHORE_ZE May 15 '16 at 18:11
  • KISHORE_ZE your link is good but i want get the "ok google xxxx" without that user say "ok google seet alarm xxxx" – Ne0ratek May 15 '16 at 18:56

0 Answers0