Search in sources :

Example 91 with SearchManager

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

the class SearchManagerTest method testSearchManagerAvailable.

/**
     * The goal of this test is to confirm that we can obtain
     * a search manager at any time, and that for any given context,
     * it is a singleton.
     */
@LargeTest
public void testSearchManagerAvailable() {
    SearchManager searchManager1 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager1);
    SearchManager searchManager2 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager2);
    assertSame(searchManager1, searchManager2);
}
Also used : ISearchManager(android.app.ISearchManager) SearchManager(android.app.SearchManager) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 92 with SearchManager

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

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 93 with SearchManager

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

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 94 with SearchManager

use of android.app.SearchManager in project HoloEverywhere by Prototik.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.i695_menu, menu);
    MenuItem item = menu.findItem(R.id.search);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            mSearchRecentSuggestions.saveRecentQuery(query, null);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem)

Example 95 with SearchManager

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

the class AssistUtils method getAssistComponentForUser.

public ComponentName getAssistComponentForUser(int userId) {
    final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Settings.Secure.ASSISTANT, userId);
    if (setting != null) {
        return ComponentName.unflattenFromString(setting);
    }
    // Fallback to keep backward compatible behavior when there is no user setting.
    if (activeServiceSupportsAssistGesture()) {
        return getActiveServiceComponentName();
    }
    Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(false);
    PackageManager pm = mContext.getPackageManager();
    ResolveInfo info = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, userId);
    if (info != null) {
        return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) SearchManager(android.app.SearchManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

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