Search in sources :

Example 71 with SearchManager

use of android.app.SearchManager in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindowManager method launchAssistAction.

private void launchAssistAction() {
    sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
    Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(mContext, true, UserHandle.USER_CURRENT);
    if (intent != null) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        try {
            mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
        } catch (ActivityNotFoundException e) {
            Slog.w(TAG, "No activity to handle assist action.", e);
        }
    }
}
Also used : SearchManager(android.app.SearchManager) ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Intent(android.content.Intent)

Example 72 with SearchManager

use of android.app.SearchManager in project android_frameworks_base by ParanoidAndroid.

the class KeyguardHostView method showAssistant.

public void showAssistant() {
    final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(mContext, true, UserHandle.USER_CURRENT);
    if (intent == null)
        return;
    final ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.keyguard_action_assist_enter, R.anim.keyguard_action_assist_exit, getHandler(), null);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mActivityLauncher.launchActivityWithAnimation(intent, false, opts.toBundle(), null, null);
}
Also used : SearchManager(android.app.SearchManager) Intent(android.content.Intent) ActivityOptions(android.app.ActivityOptions)

Example 73 with SearchManager

use of android.app.SearchManager in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindowManager method launchAssistLongPressAction.

private void launchAssistLongPressAction() {
    sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
    // launch the search activity
    Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try {
        // TODO: This only stops the factory-installed search manager.  
        // Need to formalize an API to handle others
        SearchManager searchManager = getSearchManager();
        if (searchManager != null) {
            searchManager.stopSearch();
        }
        mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
    } catch (ActivityNotFoundException e) {
        Slog.w(TAG, "No activity to handle assist long press action.", e);
    }
}
Also used : SearchManager(android.app.SearchManager) ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Intent(android.content.Intent)

Example 74 with SearchManager

use of android.app.SearchManager in project platform_frameworks_base by android.

the class AssistManager method startAssistActivity.

private void startAssistActivity(Bundle args, @NonNull ComponentName assistComponent) {
    if (!mBar.isDeviceProvisioned()) {
        return;
    }
    // Close Recent Apps if needed
    mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL);
    boolean structureEnabled = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
    final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(structureEnabled);
    if (intent == null) {
        return;
    }
    intent.setComponent(assistComponent);
    intent.putExtras(args);
    if (structureEnabled) {
        showDisclosure();
    }
    try {
        final ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.search_launch_enter, R.anim.search_launch_exit);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        AsyncTask.execute(new Runnable() {

            @Override
            public void run() {
                mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
            }
        });
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "Activity not found for " + intent.getAction());
    }
}
Also used : SearchManager(android.app.SearchManager) ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Intent(android.content.Intent) ActivityOptions(android.app.ActivityOptions)

Example 75 with SearchManager

use of android.app.SearchManager in project platform_frameworks_base by android.

the class SearchManagerTest method testStopSearchIdempotent.

/**
     * Tests that stopSearch() can be called when the search UI is not visible and can be
     * called multiple times without startSearch() in between.
     */
public void testStopSearchIdempotent() throws Exception {
    SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager);
    searchManager.stopSearch();
    searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
    searchManager.stopSearch();
}
Also used : ISearchManager(android.app.ISearchManager) SearchManager(android.app.SearchManager)

Aggregations

SearchManager (android.app.SearchManager)101 Intent (android.content.Intent)31 ISearchManager (android.app.ISearchManager)26 ActivityNotFoundException (android.content.ActivityNotFoundException)20 ComponentName (android.content.ComponentName)20 Bundle (android.os.Bundle)14 SearchView (android.support.v7.widget.SearchView)14 MenuItem (android.view.MenuItem)14 RecognizerIntent (android.speech.RecognizerIntent)12 UserHandle (android.os.UserHandle)10 View (android.view.View)9 ImageView (android.widget.ImageView)8 SearchView (android.widget.SearchView)8 TextView (android.widget.TextView)8 ActivityOptions (android.app.ActivityOptions)7 LargeTest (android.test.suitebuilder.annotation.LargeTest)6 MenuInflater (android.view.MenuInflater)6 AppWidgetHostView (android.appwidget.AppWidgetHostView)5 PackageManager (android.content.pm.PackageManager)5 ResolveInfo (android.content.pm.ResolveInfo)5