Spracherkennungslibary die ständig zuhört

@swa00
Ganz ruhig.
Ich war der Meinung, dass es genug Informationen waren und sollte noch etwas unklar sein dann frag doch bitte.

Mein Anfangsziel war es soetwas wie den Google Assistant zu programmieren.
Dann habe ich entdeckt dass da von Android was unterstützt wird, dass man seinen eigenen Assistenten entwickeln kann. Genau der Link den du gepostet hast.

Ja ich bin gerade mit dem Defaultprojekt was da von Google vorgegeben wird beschäftigt.
Das möchte ich zum laufen bringen und das dann abwandeln wir ich es brauche.

Das einzige was noch nicht funktioniert ist den Assistant zu triggern wenn man das Hotword sagt.
@jogimuc hat mich ja darauf gebracht das man wärend der Laufzeit nach der Permission BIND_VOICE_INTERACTION fragen muss und den User das bestätigen lassen muss wenn er es nochnicht hat.

Allerdings hat das so wie ich es versucht habe(siehe oben) nicht funktioniert. Bei der Permission WRITE_EXTERNAL_STORAGE hat das aber funktioniert.
Deshalb weiss ich nicht wie man nach der Permission sonst abfragen soll.
In den Einstellungen unter Apps kann ich da die Permission leider auch nicht sehen.

Ich hoffe man kann mit den Infos was anfangen. Danke für die Nerven die ihr für mich investiert.
 
Hallo so wie du das mit den permission macht wird das wohl nicht gehen. Zeige mal den gesamten Code. Am sinnvollsten macht man das in in der onCreate. Fragen und auch auf das Resultat vom User reagieren.

Auf die Antwort vom User reagierest du nicht. Sollte er es betätigt haben. Geht dein Code erst beim nechsten app start.
 
Ok also das ist die Launcher Activity die aufgerufen wird wenn man die App normal startet.
Hier wird dann in meinem Fall auch die Permission im onCreate abgefragt:
Code:
public class VoiceInteractionMain extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        findViewById(R.id.start).setOnClickListener(mStartListener);
        findViewById(R.id.secure).setOnClickListener(mSecureListener);
        if (!isPermissionsGranted()) {
            requestPermissions();
            Toast.makeText(this, "PermissionIsNotgranted", Toast.LENGTH_SHORT).show();
        }
        else {
            Toast.makeText(this, "PermissionIsGranted", Toast.LENGTH_LONG).show();
        }
    }

    private boolean isPermissionsGranted() {
        return ContextCompat.checkSelfPermission(this, Manifest.permission.BIND_VOICE_INTERACTION) == PackageManager.PERMISSION_GRANTED;
    }

    /**
     * Bestätigung der benötigten Rechte wird eingeholt.
     */
    private void requestPermissions() {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.BIND_VOICE_INTERACTION }, 0);
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public Uri onProvideReferrer() {
        return Uri.parse("http://www.example.com/VoiceInteractionMain");
    }

    View.OnClickListener mStartListener = new View.OnClickListener() {
        public void onClick(View v) {
            showAssist(null);
        }
    };

    View.OnClickListener mSecureListener = new View.OnClickListener() {
        public void onClick(View v) {
            if (((CheckBox)v).isChecked()) {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
            } else {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
            }
        }
    };
}

Das hier ist meine Manifest:
Code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.test.voiceinteraction">

    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
    <uses-permission android:name="android.permission.READ_LOGS" />

    <application>
        <activity android:name="VoiceInteractionMain" android:label="Voice Interaction"
            android:theme="@android:style/Theme.Material">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="AssistProxyActivity"
            android:label="Test Assist Proxy"
            android:theme="@android:style/Theme.NoDisplay"
            android:excludeFromRecents="true"
            android:noHistory="true"
            android:taskAffinity="">
            <intent-filter>
                <action android:name="android.intent.action.ASSIST" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name="SettingsActivity"
            android:label="Voice Interaction Settings">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <service android:name="MainInteractionService"
            android:label="Test Voice Interaction Service"
            android:permission="android.permission.BIND_VOICE_INTERACTION"
            android:process=":interactor">
            <meta-data android:name="android.voice_interaction"
                android:resource="@xml/interaction_service" />
            <intent-filter>
                <action android:name="android.service.voice.VoiceInteractionService" />
            </intent-filter>
        </service>
        <service android:name="MainInteractionSessionService"
            android:permission="android.permission.BIND_VOICE_INTERACTION"
            android:process=":session">
        </service>
        <service android:name="MainRecognitionService"
            android:label="Test Voice Interaction Service">
            <intent-filter>
                <action android:name="android.speech.RecognitionService" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="android.speech" android:resource="@xml/recognition_service" />
        </service>
        <activity android:name="TestInteractionActivity" android:label="Voice Interaction Target"
            android:theme="@android:style/Theme.Material.Light">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.VOICE" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Das ist der Service der gestartet wird wenn die App als Default Assistant in den Einstellungen gesetzt wird:
Code:
public class MainInteractionService extends VoiceInteractionService {
    static final String TAG = "MainInteractionService";

    private final Callback mHotwordCallback = new Callback() {
        @Override
        public void onAvailabilityChanged(int status) {
            Log.i(TAG, "onAvailabilityChanged(" + status + ")");
            hotwordAvailabilityChangeHelper(status);
        }

        @Override
        public void onDetected(EventPayload eventPayload) {
            Log.i(TAG, "onDetected");
        }

        @Override
        public void onError() {
            Log.i(TAG, "onError");
        }

        @Override
        public void onRecognitionPaused() {
            Log.i(TAG, "onRecognitionPaused");
        }

        @Override
        public void onRecognitionResumed() {
            Log.i(TAG, "onRecognitionResumed");
        }
    };

    private AlwaysOnHotwordDetector mHotwordDetector;

    @Override
    public void onReady() {
        super.onReady();
        Toast.makeText(this, "MainInteractionService onReady", Toast.LENGTH_SHORT).show();

        Log.i(TAG, "Creating " + this);
        mHotwordDetector = createAlwaysOnHotwordDetector(
                "Hallo", Locale.GERMAN, mHotwordCallback);
    }

    private void hotwordAvailabilityChangeHelper(int availability) {
        Log.i(TAG, "Hotword availability = " + availability);
        switch (availability) {
            case AlwaysOnHotwordDetector.STATE_HARDWARE_UNAVAILABLE:
                Log.i(TAG, "STATE_HARDWARE_UNAVAILABLE");
                break;
            case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNSUPPORTED:
                Log.i(TAG, "STATE_KEYPHRASE_UNSUPPORTED");
                break;
            case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNENROLLED:
                Log.i(TAG, "STATE_KEYPHRASE_UNENROLLED");
                Intent enroll = mHotwordDetector.createEnrollIntent();
                Log.i(TAG, "Need to enroll with " + enroll);
                break;
            case AlwaysOnHotwordDetector.STATE_KEYPHRASE_ENROLLED:
                Log.i(TAG, "STATE_KEYPHRASE_ENROLLED - starting recognition");

                break;
        }
    }
}
An den restlichen Klassen hab ich nichts verändert.
 
@swa00
Ganz ruhig.
Ich war der Meinung, dass es genug Informationen waren und sollte noch etwas unklar sein dann frag doch bitte.

Ich bin völlig tiefenentspannt :)
Und nach einigen Jahrzehnten Entwicklungs Praxis kann mich so schnell nichts erschüttern.

Nur wenn ich "Ok Google" sage dann wird was aufgerufen das dann aber gleich abstürzt.
Gib uns mal bitte deinen ErrorLog , oder stelle das CleanProjekt hier ein , damit wir ggf. selbst mal
deinen errorlog lesen können .
 
Ok also hier erstmal die Logcatausgabe. Ich hoffe da ist auch das richtige dabei.
Code:
04-25 07:43:05.367 18952-18952/com.android.test.voiceinteraction D/Zygote: CtrlSocket libc.so ctrl_sockets_set_addr pfunc is not exist!
04-25 07:43:05.371 18952-18952/com.android.test.voiceinteraction I/art: Late-enabling -Xcheck:jni
04-25 07:43:05.411 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ActivityThread,attachApplication
04-25 07:43:05.484 18952-18952/com.android.test.voiceinteraction D/HwCust: Create obj success use class android.content.res.HwCustHwResourcesImpl
04-25 07:43:05.497 18952-18952/com.android.test.voiceinteraction W/System: ClassLoader referenced unknown path: /data/app/com.android.test.voiceinteraction-2/lib/arm64
04-25 07:43:05.509 18952-18952/com.android.test.voiceinteraction D/ActivityThread: BIND_APPLICATION handled : 0 / AppBindData{appInfo=ApplicationInfo{e6a38a4 com.android.test.voiceinteraction}}
04-25 07:43:05.510 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Handling launch of ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}} startsNotResumed=false
04-25 07:43:05.514 18952-18952/com.android.test.voiceinteraction V/ActivityThread: ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}: app=android.app.Application@9643b10, appName=com.android.test.voiceinteraction, pkg=com.android.test.voiceinteraction, comp={com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}, dir=/data/app/com.android.test.voiceinteraction-2/base.apk
04-25 07:43:05.519 18952-18952/com.android.test.voiceinteraction V/HwPolicyFactory: : success to get AllImpl object and return....
04-25 07:43:05.525 18952-18952/com.android.test.voiceinteraction V/HwWidgetFactory: : successes to get AllImpl object and return....
04-25 07:43:05.535 18952-18952/com.android.test.voiceinteraction V/ActivityThread: ActivityThread,callActivityOnCreate
04-25 07:43:05.553 18952-18952/com.android.test.voiceinteraction E/MultiWindowProxy: getServiceInstance failed!
04-25 07:43:05.572 18952-18952/com.android.test.voiceinteraction D/CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.15, mControlPoint1y = 0.7, mControlPoint2x = 0.2, mControlPoint2y = 0.98
04-25 07:43:05.573 18952-18952/com.android.test.voiceinteraction D/CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
04-25 07:43:05.574 18952-18952/com.android.test.voiceinteraction D/CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.15, mControlPoint1y = 0.7, mControlPoint2x = 0.2, mControlPoint2y = 0.98
04-25 07:43:05.574 18952-18952/com.android.test.voiceinteraction D/CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
04-25 07:43:05.749 18952-18952/com.android.test.voiceinteraction D/ActivityThread: add activity client record, r= ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}} token= android.os.BinderProxy@347f9c2
04-25 07:43:05.749 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Performing resume of ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:05.750 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-AM_ON_RESUME_CALLED ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:05.750 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Resume ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}} started activity: false, hideForNow: false, finished: false
04-25 07:43:05.750 18952-18952/com.android.test.voiceinteraction V/PhoneWindow: DecorView setVisiblity: visibility = 4 ,Parent =null, this =com.android.internal.policy.PhoneWindow$DecorView{80c3609 I.E...... R.....ID 0,0-0,0}
04-25 07:43:05.752 18952-18952/com.android.test.voiceinteraction I/HwSecImmHelper: mSecurityInputMethodService is null
04-25 07:43:05.756 18952-18952/com.android.test.voiceinteraction D/WindowClient: Add to mViews: com.android.internal.policy.PhoneWindow$DecorView{80c3609 I.E...... R.....ID 0,0-0,0}, this = android.view.WindowManagerGlobal@b83a1b5
04-25 07:43:05.756 18952-18952/com.android.test.voiceinteraction D/OpenGLRenderer: Dumper init 2 threads <0x7f951ff600>
04-25 07:43:05.757 18952-18952/com.android.test.voiceinteraction D/OpenGLRenderer: <com.android.test.voiceinteraction> is running.
04-25 07:43:05.759 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: false
04-25 07:43:05.760 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: CanvasContext() 0x7fa070f000
04-25 07:43:05.772 18952-18952/com.android.test.voiceinteraction I/[MALI][Gralloc]: [+]r_hnd(0x7f950a0440), client(35), share_fd(34)
04-25 07:43:05.772 18952-18952/com.android.test.voiceinteraction D/GraphicBuffer: register, handle(0x7f950a0440) (w:1216 h:2048 s:1216 f:0x1 u:0x000100)
04-25 07:43:05.777 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Resuming ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}} with isForward=true
04-25 07:43:05.781 18952-18952/com.android.test.voiceinteraction V/PhoneWindow: DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{94f304a com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain,ident = 0}, this =com.android.internal.policy.PhoneWindow$DecorView{80c3609 V.E...... R.....ID 0,0-0,0}
04-25 07:43:05.781 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Scheduling idle handler for ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:05.782 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:05.794 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-AM_ON_PAUSE_CALLED ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:05.808 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-PAUSE_ACTIVITY handled : 1 / android.os.BinderProxy@347f9c2
04-25 07:43:06.085 18952-18952/com.android.test.voiceinteraction D/Surface: Surface::allocateBuffers(this=0x7fa1d1f000)
04-25 07:43:06.089 18952-18976/com.android.test.voiceinteraction I/OpenGLRenderer: Initialized EGL, version 1.4
04-25 07:43:06.129 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: Created EGL context (0x7f9ba53580)
04-25 07:43:06.131 18952-18976/com.android.test.voiceinteraction I/OpenGLRenderer: Get enable program binary service property (1)
04-25 07:43:06.131 18952-18976/com.android.test.voiceinteraction I/OpenGLRenderer: Initializing program atlas...
04-25 07:43:06.132 18952-18976/com.android.test.voiceinteraction D/ProgramBinary/Service: BpProgramBinaryService.getFileDescriptor
04-25 07:43:06.132 18952-18976/com.android.test.voiceinteraction D/ProgramBinary/Service: BpProgramBinaryService.getProgramMapLen
04-25 07:43:06.132 18952-18976/com.android.test.voiceinteraction D/ProgramBinary/Service: BpProgramBinaryService.getProgramMapArray
04-25 07:43:06.133 18952-18976/com.android.test.voiceinteraction D/ProgramBinary/Service: BpProgramBinaryService.getProgramBinaryLen
04-25 07:43:06.133 18952-18976/com.android.test.voiceinteraction I/OpenGLRenderer: Program binary detail: Binary length is 169616, program map length is 152.
04-25 07:43:06.133 18952-18976/com.android.test.voiceinteraction I/OpenGLRenderer: Succeeded to mmap program binaries. File descriptor is 42, and path is /dev/ashmem�.
04-25 07:43:06.133 18952-18976/com.android.test.voiceinteraction I/OpenGLRenderer: No need to use file discriptor anymore, close fd(42).
04-25 07:43:06.134 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: Initializing program cache from 0x7fa6636bc8, size = 6
04-25 07:43:06.136 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: -- init (key = 0x0000000000000000)
04-25 07:43:06.136 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: -- not init (key = 0x0000000000500040)
04-25 07:43:06.137 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: -- init (key = 0x0000000000500041)
04-25 07:43:06.138 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: -- init (key = 0x0000000800000003)
04-25 07:43:06.140 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: -- init (key = 0x0000001000500040)
04-25 07:43:06.141 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: -- init (key = 0x0000003800000000)
04-25 07:43:06.142 18952-18976/com.android.test.voiceinteraction W/OpenGLRenderer: load: so=/system/lib64/libhwuibp.so
    dlopen failed: library "/system/lib64/libhwuibp.so" not found
04-25 07:43:06.142 18952-18976/com.android.test.voiceinteraction W/OpenGLRenderer: Initialize Binary Program Cache: Load Failed
04-25 07:43:06.142 18952-18976/com.android.test.voiceinteraction D/MALI: eglCreateImageKHR:539: [Crop] 0 0 1216 2048  img[1216 2048]
04-25 07:43:06.143 18952-18976/com.android.test.voiceinteraction D/Surface: Surface::connect(this=0x7fa1d1f000,api=1)
04-25 07:43:06.144 18952-18976/com.android.test.voiceinteraction W/libEGL: [ANDROID_RECORDABLE] format: 1
04-25 07:43:06.145 18952-18976/com.android.test.voiceinteraction D/mali_winsys: new_window_surface returns 0x3000
04-25 07:43:06.218 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: CacheTexture 3 upload: x, y, width height = 0, 0, 141, 531
04-25 07:43:06.223 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [+]r_hnd(0x7f9ba5e180), client(35), share_fd(43)
04-25 07:43:06.223 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: register, handle(0x7f9ba5e180) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:06.245 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: ProgramCache save to disk, size = 6
04-25 07:43:06.258 18952-18952/com.android.test.voiceinteraction D/ActivityThread: SEND_RESULT handled : 0 / ResultData{token=android.os.BinderProxy@347f9c2 results[ResultInfo{who=@android:requestPermissions:, request=0, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }}]}
04-25 07:43:06.259 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Performing resume of ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:06.259 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-AM_ON_RESUME_CALLED ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:06.259 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Resume ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}} started activity: false, hideForNow: false, finished: false
04-25 07:43:06.259 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Resuming ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}} with isForward=false
04-25 07:43:06.260 18952-18952/com.android.test.voiceinteraction V/PhoneWindow: DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{94f304a com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain,ident = 0}, this =com.android.internal.policy.PhoneWindow$DecorView{80c3609 V.E...... R.....ID 0,0-720,1280}
04-25 07:43:06.260 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Scheduling idle handler for ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:06.260 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-RESUME_ACTIVITY handled : 0 / android.os.BinderProxy@347f9c2
04-25 07:43:06.262 18952-18952/com.android.test.voiceinteraction V/InputMethodManager: onWindowFocus: android.widget.EditText{38b75b6 VFED..CL. .F....ID 0,326-720,1032 #7f070098 app:id/text} softInputMode=32 first=true flags=#81810100
04-25 07:43:06.265 18952-18952/com.android.test.voiceinteraction V/InputMethodManager: START INPUT: android.widget.EditText{38b75b6 VFED..CL. .F....ID 0,326-720,1032 #7f070098 app:id/text} ic=com.android.internal.widget.EditableInputConnection@6157e77 tba=android.view.inputmethod.EditorInfo@ab94ae4 controlFlags=#107
04-25 07:43:06.282 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [+]r_hnd(0x7f9ba5e0e0), client(35), share_fd(45)
04-25 07:43:06.282 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: register, handle(0x7f9ba5e0e0) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:06.770 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [+]r_hnd(0x7f9ba5e4a0), client(35), share_fd(46)
04-25 07:43:06.770 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: register, handle(0x7f9ba5e4a0) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:07.230 18952-18952/com.android.test.voiceinteraction D/WindowClient: Add to mViews: android.widget.LinearLayout{12b3743 V.E...... ......I. 0,0-0,0 #21000d0 androidhwext:id/toast_layout_root}, this = android.view.WindowManagerGlobal@b83a1b5
04-25 07:43:07.235 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: CanvasContext() 0x7fa0712800
04-25 07:43:07.269 18952-18976/com.android.test.voiceinteraction D/Surface: Surface::connect(this=0x7fa1d20c00,api=1)
04-25 07:43:07.270 18952-18952/com.android.test.voiceinteraction D/Surface: Surface::allocateBuffers(this=0x7fa1d20c00)
04-25 07:43:07.272 18952-18976/com.android.test.voiceinteraction W/libEGL: [ANDROID_RECORDABLE] format: 1
04-25 07:43:07.273 18952-18976/com.android.test.voiceinteraction D/mali_winsys: new_window_surface returns 0x3000
04-25 07:43:07.287 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [+]r_hnd(0x7f9ba5e540), client(35), share_fd(49)
04-25 07:43:07.288 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: register, handle(0x7f9ba5e540) (w:373 h:82 s:384 f:0x1 u:0x000b00)
04-25 07:43:07.289 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: CacheTexture 3 upload: x, y, width height = 0, 75, 78, 477
04-25 07:43:07.315 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [+]r_hnd(0x7f9ba5e680), client(35), share_fd(50)
04-25 07:43:07.315 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: register, handle(0x7f9ba5e680) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:09.231 18952-18976/com.android.test.voiceinteraction D/Surface: Surface::disconnect(this=0x7fa1d20c00,api=1)
04-25 07:43:09.233 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: unregister, handle(0x7f9ba5e540) (w:373 h:82 s:384 f:0x1 u:0x000b00)
04-25 07:43:09.233 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [-]r_hnd(0x7f9ba5e540), client(35), share_fd(49)
04-25 07:43:09.233 18952-18976/com.android.test.voiceinteraction D/Surface: Surface::disconnect(this=0x7fa1d20c00,api=1)
04-25 07:43:09.238 18952-18952/com.android.test.voiceinteraction D/WindowClient: Remove from mViews: android.widget.LinearLayout{12b3743 V.E...... ........ 0,0-373,82 #21000d0 androidhwext:id/toast_layout_root}, this = android.view.WindowManagerGlobal@b83a1b5
04-25 07:43:12.973 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-AM_ON_PAUSE_CALLED ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}
04-25 07:43:12.990 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-PAUSE_ACTIVITY handled : 1 / android.os.BinderProxy@347f9c2
04-25 07:43:13.101 18952-18976/com.android.test.voiceinteraction D/Surface: Surface::disconnect(this=0x7fa1d1f000,api=1)
04-25 07:43:13.103 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: unregister, handle(0x7f9ba5e180) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:13.104 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [-]r_hnd(0x7f9ba5e180), client(35), share_fd(43)
04-25 07:43:13.104 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: unregister, handle(0x7f9ba5e0e0) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:13.105 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [-]r_hnd(0x7f9ba5e0e0), client(35), share_fd(45)
04-25 07:43:13.105 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: unregister, handle(0x7f9ba5e4a0) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:13.106 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [-]r_hnd(0x7f9ba5e4a0), client(35), share_fd(46)
04-25 07:43:13.107 18952-18976/com.android.test.voiceinteraction D/GraphicBuffer: unregister, handle(0x7f9ba5e680) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
04-25 07:43:13.113 18952-18976/com.android.test.voiceinteraction I/[MALI][Gralloc]: [-]r_hnd(0x7f9ba5e680), client(35), share_fd(50)
04-25 07:43:13.113 18952-18976/com.android.test.voiceinteraction D/Surface: Surface::disconnect(this=0x7fa1d1f000,api=1)
04-25 07:43:13.220 18952-18952/com.android.test.voiceinteraction V/ActivityThread: Finishing stop of ActivityRecord{354460d token=android.os.BinderProxy@347f9c2 {com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain}}: show=false win=com.android.internal.policy.HwPhoneWindow@2323150
04-25 07:43:13.227 18952-18952/com.android.test.voiceinteraction V/PhoneWindow: DecorView setVisiblity: visibility = 4 ,Parent =ViewRoot{94f304a com.android.test.voiceinteraction/com.android.test.voiceinteraction.VoiceInteractionMain,ident = 0}, this =com.android.internal.policy.PhoneWindow$DecorView{80c3609 I.E...... R......D 0,0-720,1280}
04-25 07:43:13.227 18952-18952/com.android.test.voiceinteraction D/ActivityThread: ACT-STOP_ACTIVITY_HIDE handled : 0 / android.os.BinderProxy@347f9c2
04-25 07:43:18.258 18952-18961/com.android.test.voiceinteraction I/System: FinalizerDaemon: finalize objects = 1
04-25 07:43:18.260 18952-18976/com.android.test.voiceinteraction D/OpenGLRenderer: ~CanvasContext() 0x7fa0712800

Im Anhang befindet sich mein Projekt.
 

Anhänge

  • Assist.zip
    8,6 MB · Aufrufe: 51
Ich habs leider nicht rausgefunden und durch Google werd ich auch nicht schlauer. Entweder ich suche falsch oder kein anderer hatte bisher das Problem.
 
Hallo zu deinen Post Nr. 14

welcher Callback leifert dir denn das?
Permission denke ich auch nicht mehr.


Der Callback liefert aber dann ein STATE_HARDWARE_UNAVAILABLE zurück.

Ich versteh aber nicht warum.
Die Permission android.permission.BIND_VOICE_INTERACTION hat der Service, als daran kann es schonmal nicht liegen.
 
Im MainInteractionService gibt es das Objekt android.service.voice.AlwaysOnHotwordDetector.Callback;

Code:
private final Callback mHotwordCallback = new Callback() {
        @Override
        public void onAvailabilityChanged(int status) {
            Log.i(TAG, "onAvailabilityChanged(" + status + ")");
            hotwordAvailabilityChangeHelper(status);
        }

        @Override
        public void onDetected(EventPayload eventPayload) {
            Log.i(TAG, "onDetected");
        }

        @Override
        public void onError() {
            Log.i(TAG, "onError");
        }

        @Override
        public void onRecognitionPaused() {
            Log.i(TAG, "onRecognitionPaused");
        }

        @Override
        public void onRecognitionResumed() {
            Log.i(TAG, "onRecognitionResumed");
        }
    };

private void hotwordAvailabilityChangeHelper(int availability) {
        Log.i(TAG, "Hotword availability = " + availability);
        switch (availability) {
            case AlwaysOnHotwordDetector.STATE_HARDWARE_UNAVAILABLE:
                Log.i(TAG, "STATE_HARDWARE_UNAVAILABLE");
                break;
            case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNSUPPORTED:
                Log.i(TAG, "STATE_KEYPHRASE_UNSUPPORTED");
                break;
            case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNENROLLED:
                Log.i(TAG, "STATE_KEYPHRASE_UNENROLLED");
                Intent enroll = mHotwordDetector.createEnrollIntent();
                Log.i(TAG, "Need to enroll with " + enroll);
                break;
            case AlwaysOnHotwordDetector.STATE_KEYPHRASE_ENROLLED:
                Log.i(TAG, "STATE_KEYPHRASE_ENROLLED - starting recognition");

                break;
        }
    }


In der Methode hotwordAvailabilityChangeHelper() kommt er dann in das case AlwaysOnHotwordDetector.STATE_HARDWARE_UNAVAILABLE rein.
 
In deinem LogCat kann ich das nicht finden.

"I/MainInteractionService:STATE_HARDWARE_UNAVAILABLE
wenn dein Log richtig ist geht er garnicht in dieses Case

in dem log ist kein einziger Eintrag aus der Klasse.
 
Zuletzt bearbeitet:
Die Klasse wird auch erst aufgerufen wenn man in den Einstellungen die App als Default Assistant auswählt.
[doublepost=1556307621,1556305010][/doublepost]Also ich hab das rausgefunden indem ich da eine Toastmeldung gemacht hab.
 
Oli95,

du solltest mal selbst Debuggen und das Step für Step tun und die Werte, resp Exceptions ausgeben.
Toast-Meldungen führen dich nicht produktiv ans Ziel, da dies UI-Basierte Threads sind.
 
Ich schaffe es leider nicht den MainInteractionService zu debuggen. Weil da muss man ja in die Einstellungen und das auswählen. Irgendwie wird das dann halt in LogCat nicht geloggt.
 
Ich habe mir mal eben dein Zip geladen -
erkläre mir bitte nochmal kurz , was geht , was nicht.

Und vor Allem : erkläre bitte Step für Step, was du mit deiner App erreichen möchtest
 
Zuletzt bearbeitet:
mal eine frage welcher toast kommt den eigentlich
 
Jetzt ist er off , ich sitze aber hier mit seinem Projekt ... nun denn - dann nicht :)
 
Hallo @saw00

ich habe mir auch mal das projekt geholt.
also ich bekomme nur den Toast am Anfang von der nicht vorhandenen Permission.
Die Permission kann man aber meiner Meidung so nicht holen braucht man so auch nicht.

Wenn man den Assistenten selber in den Android Einstellungen setzt. Post 30.


Ein Log aus der gesuchten Klasse
MainInteractionService
Kommt bei mir auch nicht, auch eine Tost auis der klasse kommen bei mir nicht.

Nur weiß auch nicht genau was er machen will.
 
Sorry.
Also man kann in den Einstellungen den Default Assistant auswählen.
Das findet man in Apps/Erweitert/Standart-App Einstellungen/Assistent & Spracheingabe.
Da kann man dann ganz oben die Assistenten App auswählen. Wenn man dann meine App auswählt dann wird die Klasse
MainInteractionService ausgeführt und die Toasts darin erscheinen.

und was ich möchte ist dass wenn man das Hotword sagt genau das Selbe erscheint als wenn man lang auf Home klickt.
Dafür muss man halt in den Einstellungen erst die App auswählen als Standart Assistent
 
alles schön und gut - Und dennoch nochmal die Frage :

Was soll deine App bewirken ? was möchtest du umsetzen ?

Erkläre das mal bitte für einen dummen User - Schritt für Schritt
 
Ok also ich möchte eine Sprachassistenten App.
Die Spracheingabe und dass die Befehle ausgeführt werden hab ich schon. Was mir jetzt noch fehlt ist dass die App aufgerufen wird wenn man das Hotword sagt oder lang auf Home klickt.
 

Ähnliche Themen

A
Antworten
3
Aufrufe
684
swa00
swa00
K
Antworten
1
Aufrufe
807
swa00
swa00
OnkelLon
Antworten
7
Aufrufe
1.209
thomaspan
thomaspan
Zurück
Oben Unten